Re: Compare dates
| From: | Leif K-Brooks | Date: | Mon, 29 Sep 2003 12:24:51 +0000 |
| Subject: | Re: Compare dates | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164223@lists.php.net to get a copy of this message | ||
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.