The date_add() function adds some days, months, years, hours, minutes, and seconds to a date.
PHP date_add() Function has the following syntax.
date_add(object,interval);
PHP date_add() Function has the following syntax.
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create() |
interval | Required. | DateInterval object |
PHP date_add() Function returns a DateTime object on success. FALSE on failure.
Add 40 days to the 15th of March, 2013
<?php
$date=date_create("2013-03-15");
date_add($date,date_interval_create_from_date_string("40 days"));
echo date_format($date,"Y-m-d");
?>
The code above generates the following result.