checking dates not working
| From: | Marc Fromm | Date: | Thu, 10 Nov 2011 22:35:47 +0000 |
| Subject: | checking dates not working | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-315631@lists.php.net to get a copy of this message | ||
I have this bit of code to see if a date is greater or equal to a set date.
echo(date("m/d/Y",strtotime($jobs_effective_start)));// displays entered date of
01/03/2012
echo(date("m/d/Y",strtotime(WSOFFBEGIN))); // displays set date of 09/16/2011
if (!(date("m/d/Y",strtotime($jobs_effective_start)) >=
date("m/d/Y",strtotime(WSOFFBEGIN)))) {
$error.="The effective start date must be AFTER
".WSOFFBEGIN."\n"; unset($_POST["jobs_effective_start"]);
}
My error message is displaying. The if statement is executing as true, as if 01/03/2012 is not
greater or equal to 09/16/2011.
This is not correct since a date in 2012 should be greater than a date in 2011.
If I use 12/31/2011 as the $job_effective_start date the error message is not displayed since
12/31/2011 is greater than 09/16/2011 and the if statement executes as fasle.
Any ideas on why a 2012 date is treated as not greater than a 2011 date?
Thanks
Marc