DateTime
DateTime::__construct
DateTime
PHP Manual

# DateTime::add

(PHP 5 >= 5.3.0)

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

### Opis

public DateTime DateTime::add ( string `$interval` )
DateTime date_add ( DateTime `$object` , DateInterval `$interval` )

Adds the specified DateInterval object to the specified DateTime object.

### Parametry

`object`

  Tylko styl proceduralny: Obiekt DateTime zwracany przez date_create()

`interval`

  A DateInterval object

### Zwracane wartości

Returns the modified DateTime.

### Przykłady

Przykład #1 date_add() example

`<?php
$date = new DateTime("18-July-2008 16:30:30");
echo $date->format("d-m-Y H:i:s").'<br />';
date_add($date, new DateInterval("P5D"));
echo '<br />'.$date->format("d-m-Y").' : 5 Days';
date_add($date, new DateInterval("P5M"));
echo '<br />'.$date->format("d-m-Y").' : 5 Months';
date_add($date, new DateInterval("P5Y"));
echo '<br />'.$date->format("d-m-Y").' : 5 Years';
date_add($date, new DateInterval("P5Y5M5D"));
echo '<br />'.$date->format("d-m-Y").' : 5 Days, 5 Months, 5 Years';
date_add($date, new DateInterval("P5YT5H"));
echo '<br />'.$date->format("d-m-Y H:i:s").' : 5 Years, 5 Hours';
?>`

### Zobacz też:

- DateTime::sub() - Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
- DateTime::diff() - Returns the difference between two DateTime objects

DateTime
DateTime::__construct
DateTime
PHP Manual