我试图验证一周中的某一天是否等于星期三 (3),如果我按以下方式操作,这很有效。
var today = new Date();
if (today.getDay() == 3) {
alert('Today is Wednesday');
} else {
alert('Today is not Wednesday');
}
但我无法对时区做同样的事情。
var todayNY = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
if (todayNY.getDay() == 3) {
alert('Today is Wednesday in New York');
} else {
alert('Today is not Wednesday in New York');
}
LEATH
PIPIONE
相关分类