Re: Difference between 2 Dates
| From: | DL Neil | Date: | Fri, 13 Dec 2002 22:49:45 +0000 |
| Subject: | Re: Difference between 2 Dates | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128218@lists.php.net to get a copy of this message | ||
Colin,
> I have a similar problem. I am trying to figure out which of two dates
> is greater. Both are in the yyyy-mm-dd format. Is there any easy
> function that allows this sort of comparison or am I missing something?
Treat the dates as strings not numbers:
$DateOne = "2002-12-13";
$DateTwo = "2001-11-12";
if ( $DateOne <= $DateTwo ) echo "DateOne comes first";
You can do comparisons like this but don't try any 'arithmetic'!
Regards,
=dn