Add 1 day to Datetime?

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
zachbb
Forum Newbie
Posts: 2
Joined: Wed Aug 04, 2010 1:47 am

Add 1 day to Datetime?

Post by zachbb »

I have a DateTime variable, which I display in this format:
"Y-m-d H:i"

I would like to add 1 day to the variable. I can't just do +1 as there are a limited number of days in a month (e.g. never 32)! It would have to go to the next month when neccessary.

Any ideas?
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Add 1 day to Datetime?

Post by internet-solution »

Try

Code: Select all

date("Y-m-d H:i",strtotime($date." +1 day"))
zachbb
Forum Newbie
Posts: 2
Joined: Wed Aug 04, 2010 1:47 am

Re: Add 1 day to Datetime?

Post by zachbb »

Thanks! Worked great!

Thanks again!
Post Reply