I have some trouble comparing the fields to current time.
I have two fields in MySQL, who record the start time and end time of a lecture.
What I'm trying to do is check if the current time is during the start time and the end time.
$starttime and $endtime are in forms of DateTime.
The code's here:
$now = time();
$compare = mysql_query("SELECT * FROM lecture WHERE strtotime(starttime) < '$now' AND '$now' < strtotime(endtime)");
But it doesn't work.
I also tried this:
$now = new DateTime;
$compare = mysql_query("SELECT * FROM lecture WHERE starttime < '$now' AND '$now' < endtime");
But it broke too.
Could anyone tell me how to realize it? Many thanks.