I have a start time of 3:30 pm and end time of 4:14:59 pm. Bot开发者_如何学Ch the values are strings so I used strtotime() to convert them. I'm not sure it is taking into account the am while testing. I want to get the current time and check to see if the current time is between those two values.
$server_time = strtotime("3:55 AM");
if($server_time > strtotime($start) && $server_time < strtotime($end))
{
echo "TRUE";
}
else
{
echo "FALSE";
}
This should be false considering my server time is AM and my start and end are both PM. This is returning true though. Is there a better way to handle this?
Any help would be appreciated.
strtotime is extremely picky, i tend to use it only for mysql date conversion to timestamp. There should be no problem analyzing dates with AM and PM, but for the sake of simplicity, use military times if you don't want to have troubles converting your dates.
For example:
Military: 16:34:59
Standard: 4:34:59 PM
精彩评论