Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP date_diff() Function

PHP date_diff() Function

PHP Date/Time PHP Date/Time Reference Manual

Example

Calculate the difference between two dates:

Run Example »


Definition and Usage

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

Syntax

date_diff(

datetime1,datetime2,absolute);

Parameters Description
datetime1 Required. Specifies a DateTime object.
datetime2 Required. Specifies a DateTime object.
absolute Optional. Specifies a boolean. TRUE means the interval/difference must be positive. Default is FALSE.

Technical Details

Return Value: Returns a DateInterval object representing the difference between the two dates on success, or FALSE on failure.
PHP Version: 5.3+

PHP Date/Time PHP Date/Time Reference Manual