Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

date_add

Description

The date_add of Date / Time for PHP adds an amount of days, months, years, hours, minutes and seconds to a DateTime object.

Syntax

date_add ( DateTime $object , DateInterval $interval ) : DateTime

Parameters

object

A DateTime object returned by date_create(). The function modifies this object.

interval

A DateInterval object

Return

Returns the DateTime object for method chaining or FALSE on failure.

Examples

1

<?

$object = date_create('2001-01-01');
$interval = date_interval_create_from_date_string('1 year 1 month 1 day');

$return = date_add($object, $interval);

echo date_format($object, 'Y-m-d') . PHP_EOL;
echo date_format($return, 'Y-m-d');

?>
2002-02-02
2002-02-02
HomeMenu