我试图做的是检查当前时间是否在一周中大多数日子不同的特定时间段内。我已经尝试了大约 6 种不同的方法,它会做一次 else 并且永远不会再完全难倒我,所以我想我会请求蜂巢的帮助。
这是我目前所拥有的。
/**
* Simple Array Storing the times to block on each day
*/
$nonNewDay = array(
array(
'2:00 am',
'11:00 am'
),
array(
'2:00 am',
'11:00 am'
),
array(
'2:00 am',
'11:00 am'
),
array(
'2:00 am',
'11:00 am'
),
array(
'2:00 am',
'11:00 am'
),
// Weekends
array(
'2:00 am',
'1:00 pm'
),
array(
'2:00 am',
'12:00 pm'
),
);
// Get Current weekday and time;
$weekday = date('w');
$date = date('m-d-Y');
$time = date('g:00 a', strtotime('now'));
echo $date;
echo '<br />';
echo $time;
echo '<br />';
/**
* Were Attempting to block out all time blocks that are NOT "New Day Programming"
* Which currently are:
* Mon - Fri 11:00 am - 2:00 am
* Sat, Sun 2:00 am - 1PM
*/
if (strtotime($date . ' ' . $time) <= strtotime($date . ' ' . $nonNewDay[$weekday - 1][0]) && strtotime($date . ' ' . $time) >= strtotime($date . ' ' . $nonNewDay[$weekday - 1][1])) {