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";
elseif($ts1 == $ts2):
         echo "date 1 is equal to date 2" ;
else:
         echo " date 2 is greater than date 1";
endif;

should work :)
Tom
At 09:50 AM 28/03/01 +0000, kaab kaoutar wrote:
>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, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to