I have two variables containing strings of dates in the format
$four_days_have_passed = "07-14-2013";
$now = "07-10-2013";
I have checked the output in FirePHP and the dates are correct.
Then I try to compare them like this,
if (strtotime($now) < strtotime($four_days_have_passed))
{
Do Stuff
}
Why does the code inside the IF statement never execute?
If you want to use MM/DD/YYYY format you need /
separator.
$four_days_have_passed = "07/14/2013";
$now = "07/10/2013";
From the manual:-
Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With