Home Tutorial Php Phpdate date_diff

 
 

date_diff
Posted on: August 25, 2009 at 12:00 AM
Advertisement
This is the example of finding the date difference in PHP.

date_diff

date_diff alias DateTime::diff returns the difference between two DateTime objects. It returns the difference of two dates, if it exists or return zero.

Description

public DateInterval DateTime::diff ( DateTime $datetime [, bool $absolute ] )

Parameters

datetime - The date to compare to.

absolute - Whether to return absolute difference. Defaults to FALSE.

Example:

<?php
$start = new DateTime('08-24-2009 India/Kolkata'); // DD-MM-YYYY
$end = new DateTime('07-15-1998 UAE/Dubai');

if ($start < $end) {
echo "Correct order";
} else {
echo "Incorrect order, end date is before the starting date";
}
?>

Advertisement

Related Tags for date_diff:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 25, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com