I am using this to count the days till it expires
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}
$expiry_date = "07-11-2106";
$today = date('m-d-Y');
echo dateDiff("-",$expiry_date,$today); // # of days
echo "<br />";
which works fine. But if I change the $expiry_date = "2106-07-11" and $today = date('Y-m-d') it stops working. I need it to be in Y-m-d formate ..what can I do. Thanks
int gregoriantojd ( int $month , int $day , int $year )
so change the function to the one below and it will work in the other format:
Open in new window