$date = date('Y-m-d',current_time('timestamp', 0));
How do I change $date to $date + 5 days?
PHP version is 5.2.
This code doesn’t work:
$date_cur = date('Y-m-d',current_time('timestamp', 0));
echo $date_cur . ' <br>';
$date_cur_plus = date($date_cur, strtotime('+5 days'));
echo $date_cur_plus;
Gives me:
2011-11-29
2011-11-29
You could use
mktime()using the timestamp.Something like:
Using
strtotime()is faster, but my method still works and is flexible in the event that you need to make lots of modifications. Plus,strtotime()can’t handle ambiguous dates.Edit
If you have to add 5 days to an already existing date string in the format
YYYY-MM-DD, then you could split it into an array and use those parts withmktime().