开发者

JavaScript Date Function

开发者 https://www.devze.com 2022-12-23 07:37 出处:网络
I\'m using the following function that changes a calendar selection at a set time during the day (all code works perfectly).

I'm using the following function that changes a calendar selection at a set time during the day (all code works perfectly). However, I'd like to modify it slightly so that on a SATURDAY the dd=dd+1 becomes dd=dd+2, because I want to skip Sunday. Can 开发者_StackOverflow中文版anyone help?

$(function() {       
var dd = 0
if (<%= currentHour %> > <%= cutoffHour %>) {
dd = dd + 1; // go one day in the future
}


I'm not sure whether I understood you correctly but change dd = dd + 1; into something like this:

dd = (dd == 5) ? dd + 2 : dd + 1

I don't know how do you determine SATURDAY but I guess as a numeric value where Saturday is 5 or 6.

EIDT:

if (6 == new Date().getDay()) {
    dd += 2;
}
0

精彩评论

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

关注公众号