我正在制作一个调度应用程序,并且我坚持使用以下逻辑。我有一个时隙数组,如果当前时间是晚上7点之后,我想隐藏第二天上午9点之前的时隙。例如,如果当前时间是8/25/2014 7:01pm,那么在8/26/2014 9:00am之前的所有时隙都不应该出现。
I tried this
if(date('Y-m-d H:i:s', strtotime('7:00pm')) <= $from && $from <= date('Y-m-d H:i:s', strtotime('+1 day 9:00am')) && $now > date('Y-m-d H:i:s', strtotime('7:00pm')))
continue;
但strtotime('7:00pm')
返回当天的下午7点。
问题是如何获得日期时间,也就是说,$from
前一天的晚上7:00 ?
尝试将日期$from与7:00pm连接起来,如:
$start_date = $date('Y-m-d', $from)." "."7:00pm";
// then use it in strtotime
date('Y-m-d H:i:s', strtotime($start_date));