根据营业时间确定业务是否开放/关闭
如果时间是 AM 到 PM(例如:上午 11 点 - 晚上 10 点),我的代码可以正常工作,但如果位置营业时间是 AM 到 AM(例如:9 AM - 1 AM),它会中断。这是我的代码:
$datedivide = explode(" - ", $day['hours']); //$day['hours'] Example 11:00 AM - 10:00 PM
$from = ''.$day['days'].' '.$datedivide[0].'';
$to = ''.$day['days'].' '.$datedivide[1].'';
$date = date('l g:i A');
$date = is_int($date) ? $date : strtotime($date);
$from = is_int($from) ? $from : strtotime($from);
$to = is_int($to) ? $to : strtotime($to);
if (($date > $from) && ($date < $to) && ($dateh != 'Closed')) {
?>
<script type="text/javascript">
$(document).ready(function(){
$('.entry-title-container').append('<div class="column two"><h2 style="color:green;text-align: left;margin: 0;">OPEN<br /><span style="color:#222;font-size:12px;display: block;">Closes at <?php echo $datedivide[1]; ?></span></h2></div><br clear="all" />');
});
</script>
<?php
}