Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Day to Timestamp

How do I add days to a timestamp? If my timestamp is 01-JAN-2011 11-09-05 and I add 2 days, I want 03-JAN-2011 11-09-05.

like image 384
Nadir Avatar asked May 26 '11 17:05

Nadir


People also ask

How do you add 24 hours to a timestamp?

echo time() + (24*60*60);

How much is a day in timestamp?

1 Day: 86,400 seconds.

How do I add 7 days to a date?

Just do: $date = strtotime("+7 day"); echo date('M d, Y', $date);

How do you add days in date in react JS?

Adding days to current Date const current = new Date(); Now, we can add the required number of days to a current date using the combination of setDate() and getDate() methods.


2 Answers

select '01-jan-2011 11-09-05' + interval '2' day
like image 142
Marc B Avatar answered Sep 24 '22 13:09

Marc B


A completely Oracle-centric solution is to simply add 2 to the timestamp value as the default interval is days for Oracle dates/timestamps:

SELECT TO_TIMESTAMP('01-jan-2011 11-09-05','DD-Mon-YYYY HH24-MI-SS') + 2
  FROM dual;
like image 31
DCookie Avatar answered Sep 23 '22 13:09

DCookie