Page 1 of 1

Adding/subtracting of dates

Posted: Thu Sep 18, 2008 3:21 pm
by LindaT
Hi,

Given a date, is there a function for adding/subtracting a variable number of days which will return the new date? The date_add and date_sub functions don't return a date and these are only experimental functions.

Thanks.

Re: Adding/subtracting of dates

Posted: Thu Sep 18, 2008 4:02 pm
by ansi,
strtotime()

example:

Code: Select all

 
echo date("F d Y g:i:sa", strtotime("12 Jan 2008 1:00:00pm + 3 days"));
 
though iirc, date_add and date_sub are mysql functions so you could do say "now() + interval 3 day"