Reputation: 3267
How can I find the next day's date after a given date.
For example, I have a date 2011-11-31
. How can I get the next date (2011-12-01
) using PHP?
Similarly, how would I get the previous day's date?
Upvotes: 0
Views: 901
Reputation: 2265
You can use the strtotime() function in php:
$date="2011-11-11";
$nextdate = date('Y-m-d', strtotime($date . " +1 day"));
echo $nextdate;
It will echo as "2011-11-12".
Similarly to find the previous date use:
$nextdate = date('Y-m-d', strtotime($date . " -1 day"));
It will echo as "2011-11-10".
Upvotes: 0
Reputation: 324750
$nextdate = date("Y-m-d",strtotime($olddate." +1 day"));
Upvotes: 5