Moment 中的弃用警告.js - 不是识别的 ISO 格式
2022-08-30 00:42:51
我收到一条警告,指出提供给时刻的值不是公认的 ISO 格式。我今天用时刻函数更改了我的变量,但它仍然不起作用。
这是警告错误:
弃用警告:提供的值不是可识别的 ISO 格式。时刻构造回退到js Date(),这在所有浏览器和版本中都不可靠。不鼓励使用非 ISO 日期格式,这些格式将在即将推出的主要版本中删除。有关详细信息,请参阅 http://momentjs.com/guides/#/warnings/js-date/。参数: [0] _isAMomentObject: 真, _isUTC: 真, _useUTC: 真, _l: 未定义, _i: 2016-9-26 19:30, _f: 未定义, _strict: 未定义, _locale: [对象对象]
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);
});