Friday, 23 January 2015

Date Difference - Php

This code used to find difference between two date
<?php

function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
$end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
return $end_date - $start_date;
}

$curdate=date('Y-m-d');
$predate="2009-12-16";
echo dateDiff("-", $curdate, $predate);
?>

0 comments:

Post a Comment