You are doing a string compare not date, convert them to a unix time stamp
and then compare
$d1 = explode("-",$date1);
$d2 = explode("-",$date2);
$ts1 = mktime(0,0,0,$d1[1],$d1[2],$d1[0]);
$ts2 = mktime(0,0,0,$d2[1],$d2[2],$d2[0]);
if( $ts1 > $ts2 ):
echo "Date 1 is greater than date2";
What are appropriate functions to do Date and Time comparison?
like:
Date difference
Date Comparison?
Adding 'n' days to current date string value, Removing 'n' month, etc.
Where can i find the date integer enconding used in PHP?
Like i know how it's done in Delphi (as stored as a Doub
If you _do_ want to use this method for comparing dates (which isn't
realy a usual way of doing it... there date-functions) you should
fill up with leading 0's, like:
$date1="2001-01-07"; $date2="2001-01-14";
The reason is _very_ simple... You performing a text-compare here.
And let's face it...
Hi!
$date1="2001-1-7";$date2="2001-1-14";
if ($date1>=$date2) echo "date1 is greater then date2";
else echo "date2 is greater then date1";
the result is the first :(
but it works for other dates!
Thanks
_
Get Your Private,
4 matches
Mail list logo