How do I select only a column of times (e.g., 10:15, 10:35) using PHP and how can I compare those with the current time?
So in one table I have a column of time values, just a bunch of time values like 10:15, 10:35, etc. Another column has AM/PM as a text. I'm so confused as to how to do this. How do I take those values and compare it with the current time using PHP? I know you have to do a $sql statement but then what?
Also, if it's easier for any of your answers I can 开发者_开发问答add the AM/PM to the time value column so it would be 10:15 AM, 10:35 AM as a text value instead of just the numbers.
You can use the function strtotime
In particular:
<?php
$now = time();
$some_time = strtotime('11:20 PM');
if($now > $some_time)
echo "you are late";
else
echo "you have time";
?>
精彩评论