You can use mktime()
using a timestamp.
Sort of:
$date = date('Ym-d', mktime(0, 0, 0, date('m'), date('d') + 5, date('Y')));
Using strtotime()
is faster, but my method still works and is flexible when you need to make a lot of changes. In addition, strtotime()
cannot handle ambiguous dates.
Edit
If you need to add 5 days to an existing date string in YYYY-MM-DD
format, you can split it into an array and use those parts with mktime()
.
$parts = explode('-', $date); $datePlusFive = date( 'Ym-d', mktime(0, 0, 0, $parts[1], $parts[2] + 5, $parts[0])
source share