PHP ManualDateTime::adddate_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 DescriptionObject oriented style Procedural style Adds the specified DateInterval object to the specified DateTime object. Parameters
Return Values
Returns the DateTime object for method chaining or ExamplesExample #1 DateTime::add() example Object oriented style
<?php Procedural style
<?php The above examples will output: 2000-01-11 Example #2 Further DateTime::add() examples
<?php The above example will output: 2000-01-01 10:00:30 2007-06-05 04:03:02 Example #3 Beware when adding months
<?php The above example will output: 2001-01-31 2001-03-03 NotesDateTime::modify() is an alternative when using PHP 5.2. See Also
![]() |
PHP-Index
New Tutorial entries
|