syedasimmeesaq
asked on
date problem
I am using this to count the days till it expires
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dfor mat, $beginDate);
$date_parts2=explode($dfor mat, $endDate);
$start_date=gregoriantojd( $date_part s1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($d ate_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
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dfor
$date_parts2=explode($dfor
$start_date=gregoriantojd(
$end_date=gregoriantojd($d
return $end_date - $start_date;
}
$expiry_date = "07-11-2106";
$today = date('m-d-Y');
echo dateDiff("-",$expiry_date,
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Works!
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