가게 정보 중 '영업 중' 표시되게 하기
본문
if(strtotime($open) < strtotime($now) && strtotime($close) > strtotime($now)){
echo 'open';
} else {
echo 'close';
}
위와 같이 현재 시간이 오픈 후, 마감 전 일때는 open 이라는 글이 뜨게 할려고 하는데요.
문제는 마감시간이 새벽 2시일 경우 현재시간 오후 7시보다 작기 때문에 close 라고 뜹니다.
이럴때는 어떻게 해야 하나요?
!-->답변 2
$open $close 가 매 open close 때마다 now()로 저장된게 아니고 시간만 고정으로 저장해 놓으셨다면
$close_temp = $close;
if(str_replace(":","",$close)<str_replace(":",$open)){
$close_temp = strtotime(strtotime($close). ' +1 day');
}
if(strtotime($open) < strtotime($now) && strtotime($close_temp ) > strtotime($now)){
echo 'open';
} else {
echo 'close';
}
&& 가 아닌 || 로 사용해보세요
답변을 작성하시기 전에 로그인 해주세요.