Re: comparing dates works sometimes and fails another time!
| From: | Renze Munnik | Date: | Wed, 28 Mar 2001 10:13:23 +0000 |
| Subject: | Re: comparing dates works sometimes and fails another time! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45866@lists.php.net to get a copy of this message | ||
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... the characters "-1" (day of date2) are
"smaller" than "-7" (day in date1).
So...
RenzE
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: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net