【发布时间】:2015-08-04 15:22:52
【问题描述】:
我目前正在使用我在上一篇文章中找到的一些脚本。它会根据日期和时间显示打开或关闭。
$(document).ready(function() {
"use strict";
var Now = new Date();
var CurrentDay = Now.getDay();
// opening time - 24 hours so 9:30am is 9, 30
var OpeningTime = new Date(Now.getFullYear(), Now.getMonth(), Now.getDate(), 8);
// closing time - 24 hours so 5:30pm is 17, 30
var ClosingTime = new Date(Now.getFullYear(), Now.getMonth(), Now.getDate(), 20);
var Open = (Now.getTime() > OpeningTime.getTime() && Now.getTime() < ClosingTime.getTime());
// days 0.sun 1.mon 2.tues 3.wed 4.thur 5.fri 6.sat
// CurrentDay !== 0 && the # is the day to eclude, so if I want to be closed on Sat6, Sun0, Wed3
// CurrentDay !== 6 && CurrentDay !== 0 && CurrentDay !== 3 && Open
if (CurrentDay !== 1 && CurrentDay !== 5 && Open) {
$('.openstatus').toggle();
}
});
目前将其设置为周一至周五上午 8 点至下午 8 点。但我也想在周六上午 9 点至下午 5 点和周日上午 10 点至下午 4 点之间显示开放文本
任何建议将不胜感激。
非常感谢。
【问题讨论】:
标签: javascript jquery