Anonymous user / 3.142.144.40 Log In Register
?
Wallet: 3.00
Daily Credits:
1.20 / 1.20

PHP Functions Online


DateTime::add

(PHP 5 >= 5.3.0)

DateTime::add -- date_add Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object

public DateTime $object->add(DateInterval $interval)
public DateTime::__construct([string $time = "now"[, DateTimeZone $timezone = NULL]])
public DateTimeZone::__construct(string $timezone)
public DateInterval::__construct(string $interval_spec)

Checkout ? #

Item Description Item Price Your Price
Total

Preview #

${{ variable.param.name }} = {{ variable.param|getValue:variable.form:true }};
{{ call.result}} = ;

Tip: You can change some values by clicking on it in the preview above.

Description #

public DateTime DateTime::add ( DateInterval $interval )

Adds the specified DateInterval object to the specified DateTime object.

Parameters #

interval

A DateInterval object

Return Values #

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

Examples #

Example #1 DateTime::add() example

Object oriented style

<?php
$date 
= new DateTime('2000-01-01');
$date->add(new DateInterval('P10D'));
echo 
$date->format('Y-m-d') . "\n";
?>

Procedural style

<?php
$date 
date_create('2000-01-01');
date_add($datedate_interval_create_from_date_string('10 days'));
echo 
date_format($date'Y-m-d');
?>

The above examples will output:

2000-01-11

Notes #

DateTime::modify() is an alternative when using PHP 5.2.

See Also #