Reputation: 1384
I am running this PHP Code:
$earliest='2013-11-19 23:00:00';
$latest='2013-11-19 01:00:00';
if(isset($earliest) and isset($latest))
{
if(date("Y-m-d H:i:s") >= $earliest and date("Y-m-d H:i:s") <= $latest)
{
echo 'yes';
}
else
{
echo 'no';
}
}
the current date/time (2013-11-19 12:52:00) is > or = to the $earliest variable but its displaying no
any ideas why this would be? have i done something wrong in my code?
if i do just:
if(date("Y-m-d H:i:s") <= $latest)
it displays yes
Upvotes: 1
Views: 60
Reputation: 2612
Your comparison operators are incorrect:
if(date("Y-m-d H:i:s") >= $earliest and date("Y-m-d H:i:s") <= $latest)
should be:
if(date("Y-m-d H:i:s") >= $earliest && date("Y-m-d H:i:s") <= $latest)
Upvotes: 0