You might try converting these dates to Unix time and then compare the
numbers as integers.
Let's see, here is a function that converts the data from a MySQL date field
to a Unix timestamp...
function mysql_to_epoch ($datestr)
{
list($year,$month,$day,$hour,$minute,$second) =
split("([^0-9])",$datestr);
return date("U",mktime($hour,$minute,$second,$month,$day,$year));
}
And here is where I use it to calculate the age of the item in the database.
$epochTime = mysql_to_epoch($messageCreated);
$currentEpochTime = time();
$ageInSeconds = $currentEpochTime - $epochTime;
I hope this provides a clue for your application.
John
> -----Original Message-----
> From: Chris [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 08, 2001 12:12 PM
> To: php
> Subject: [PHP] Date Question
>
>
> Hi,
> Since there is no Date type in php, is there a way to compare dates?
>
> Something like:
>
> if ((3/8/2001) < (3/9/2001)){
> // Date is newer
> }
>
> Thanks,
> Chris
>
--
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]