X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP date_diff() Function

PHP Date/Time PHP Date/Time Reference

Example

Calculate the difference between two dates:

<?php
$date1=date_create("2013-03-15");
$date2=date_create("2013-12-12");
$diff=date_diff($date1,$date2);
?>

Run example »

Definition and Usage

The date_diff() function returns the difference between two DateTime objects.


Syntax

date_diff(datetime1,datetime2,absolute);

Parameter Description
datetime1 Required. Specifies a DateTime object
datetime2 Required. Specifies a DateTime object
absolute Optional. Specifies a Boolean value. TRUE indicates that the interval/difference MUST be positive. Default is FALSE

Technical Details

Return Value: Returns a DateInterval object on success that represents the difference between the two dates. 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 HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook