X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP date_add() Function

PHP Date/Time PHP Date/Time Reference

Example

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");
?>

Run example »

Definition and Usage

The date_add() function adds some days, months, years, hours, minutes, and seconds to a date.


Syntax

date_add(object,interval);

Parameter Description
object Required. Specifies a DateTime object returned by date_create()
interval Required. Specifies a DateInterval object

Technical Details

Return Value: Returns a DateTime object on success. FALSE on failure
PHP Version: 5.3+


PHP Date/Time PHP Date/Time Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook