最佳答案
我得到一个警告,提供给moment的值不是公认的ISO格式。今天我用矩函数改变了变量,但它仍然不起作用。
下面是警告错误:
弃用警告:所提供的值不是公认的ISO格式。moment构造回到js Date(),它在所有浏览器和版本上都不可靠。不鼓励使用非ISO日期格式,并将在即将发布的主要版本中删除。更多信息请参考http://momentjs.com/guides/#/warnings/js-date/。 参数: [0] _isAMomentObject: true, _isUTC: true, _useUTC: true, _l: undefined, _i: 2016-9-26 19:30, _f: undefined, _strict: undefined, _locale: [object object]
. > . [0] _isAMomentObject: true, _isUTC: true, _useUTC: true, _l: undefined, _i: 2016-9-26 19:30, _f: undefined, _strict: undefined, _locale: [object object] . [0]
var entryDate = new Date();
var currentDate = entryDate.getDate();
function between(x, min, max) {
return x.valueOf() >= min.valueOf() && x < max.valueOf();
}
$('#custom1').change(function () {
if ($('#custom1 :selected').val() == 'AU') {
var keyword = '';
var aus1_s = moment.tz('2016-9-26 19:30', 'Australia/Sydney');
var aus2_s = moment.tz('2016-10-2 19:30', 'Australia/Sydney');
var aus3_s = moment.tz('2016-10-9 19:30', 'Australia/Sydney');
var aus4_s = moment.tz('2016-10-16 19:30', 'Australia/Sydney');
var aus5_s = moment.tz('2016-10-23 19:30', 'Australia/Sydney');
var aus6_s = moment.tz('2016-10-30 19:30', 'Australia/Sydney');
var aus6_e = moment.tz('2016-11-5 19:30', 'Australia/Sydney');
} else if ($('#custom1 :selected').val() == 'NZ') {
var aus1_s = moment.tz('2016-9-28 20:30', 'Pacific/Auckland');
var aus2_s = moment.tz('2016-10-4 20:30', 'Pacific/Auckland');
var aus3_s = moment.tz('2016-10-11 20:30', 'Pacific/Auckland');
var aus4_s = moment.tz('2016-10-18 20:30', 'Pacific/Auckland');
var aus5_s = moment.tz('2016-10-25 20:30', 'Pacific/Auckland');
var aus6_s = moment.tz('2016-11-2 20:30', 'Pacific/Auckland');
var aus6_e = moment.tz('2016-11-9 20:30', 'Pacific/Auckland');
} else {
$('#entryEquals').val('');
return false;
}
var today = moment();
switch (true) {
case between(today, aus1_s, aus2_s):
keyword = 'RElYT04=';
break;
case between(today, aus2_s, aus3_s):
keyword = 'QlJJREU=';
break;
case between(today, aus3_s, aus4_s):
keyword = 'U1lETkVZ';
break;
case between(today, aus4_s, aus5_s):
keyword = 'R1JPT00=';
break;
case between(today, aus5_s, aus6_s):
keyword = 'V0VERElORw==';
break;
case between(today, aus6_s, aus6_e):
keyword = 'VExD';
break;
default:
$('#entryEquals').val('');
break;
}
$('#entryEquals').val(keyword);
});