compare dates
| From: | Marc Fromm | Date: | Wed, 30 Nov 2011 22:00:40 +0000 |
| Subject: | compare dates | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-315906@lists.php.net to get a copy of this message | ||
I'm puzzled why the if statement executes as true when the first date (job_closedate) is not
less than the second date (now).
The if statement claims that "12/02/2011" is less than "11/30/2011".
if (date("m/d/Y",strtotime($jobs_closedate)) <=
date("m/d/Y",strtotime("now"))){
echo date("m/d/Y",strtotime($jobs_closedate)); // displays - 12/02/2011
echo date("m/d/Y",strtotime("now")); // displays
- 11/30/2011
$error.="The close date must be later than today's date,
" . date("m/d/Y",strtotime("now")) . ".\n";
}
If the first date is "11/16/2011" the if statement also executes as true which is correct
since "11/16/2011" is less than "11/30/2011".
Marc