开发者

what's the fastest way to tell whether we're on a weekday in a particular hour range?

开发者 https://www.devze.com 2023-04-07 14:58 出处:网络
I am using PHP/MySQLin my project, and I have a table that holds time values, and days of week. The rows are SUNDAY_OPEN SUNDAY_CLOSE etc. for the rest of the week. These hold times like 9:00 and 17:0

I am using PHP/MySQLin my project, and I have a table that holds time values, and days of week. The rows are SUNDAY_OPEN SUNDAY_CLOSE etc. for the rest of the week. These hold times like 9:00 and 17:00.

All I want to do is on a certain time of access, to know whether the NOW() or time() in PHP fall exactly on that time开发者_如何学运维 range.


How about something like:

$day_of_week = strtoupper(date("l"));
$current_hour = date("G:i");
$sql = "
    SELECT COUNT(*) AS `open`
    FROM `schedule`
    WHERE '{$current_hour}' BETWEEN `{$day_of_week}_OPEN` AND `{$day_of_week}_CLOSE`";
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号