寻找一个简单的jQuery代码来调度JavaScript代码(JavaScript用于纯聊天)。JavaScript代码应该在格林尼治时间9-5:30运行。
所以应该是这样:
JQ function (mo - fr, 9 - 5:30) {
js window.purechatApi etc
}
发布于 2016-02-13 06:53:08
您可以使用下面的javascript代码来确定当前日期。getDay()函数返回从0到6的数值,这分别是从星期日到星期六的日子。您必须添加
var d = new Date();
var n = d.getDay();
if(n >=1 && n<=5)
{
// 1 for monday and 5 for friday
// your code to check date and time
var currentD = new Date();
var startChat = new Date();
startChat.setHours(9,00,0); // 9.00 am
var endChat = new Date();
endChat.setHours(17,30,0); // 5.30 pm
if(currentD >= startChat && currentD < endChat ){
console.log("yes!");
}else{
console.log("chat off");
}
}
https://stackoverflow.com/questions/35376943
复制相似问题