Increase current date by 5 days

You could use mktime() using the timestamp.

Something like:

$date = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + 5, date('Y')));

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 with mktime().

$parts = explode('-', $date);
$datePlusFive = date(
    'Y-m-d', 
    mktime(0, 0, 0, $parts[1], $parts[2] + 5, $parts[0])
    //              ^ Month    ^ Day + 5      ^ Year
);

$date = date('Y-m-d', strtotime('+5 days'));

Tags:

Php

Date