Adding/subtracting of dates

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LindaT
Forum Newbie
Posts: 1
Joined: Thu Sep 18, 2008 3:14 pm

Adding/subtracting of dates

Post 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.
ansi,
Forum Newbie
Posts: 3
Joined: Thu Sep 18, 2008 11:03 am

Re: Adding/subtracting of dates

Post 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"
Post Reply