Shaun wrote:

How can I compare two dates with PHP, to see if one date occurred before the
other?


Convert them to a timestamps (strtotime()), then just compare them:

$date1 = 'september 10th 2003';
$date2 = 'september 20th 2003';

$date1_ts = strtotime($date1);
$date2_ts = strtotime($date2);

if($date1_ts < $date2_ts){
    echo 'Date 1 is before date 2.';
}else{
    echo 'Date 2 is before date 1.';
}

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to