我正在制作一个计划应用程序,并且我坚持使用以下逻辑。 我有一系列时间段,如果当前时间是晚上7点以后,我想隐藏第二天上午9:00之前的时段。例如,如果当前时间日期是8/25/2014 7:01 pm,则不应出现在2014年8月26日上午9:00之前的所有时间段。
我试过这个
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点的前一天?
答案 0 :(得分:0)
尝试将日期$从晚上7点连接起来,例如:
$start_date = $date('Y-m-d', $from)." "."7:00pm";
// then use it in strtotime
date('Y-m-d H:i:s', strtotime($start_date));