我收到警告,提示提供的值不是公认的ISO格式。我今天用矩函数更改了变量,但仍然无法正常工作。
这是警告错误:
弃用警告:提供的值不是公认的ISO格式。此刻的构建要归结到js Date(),它在所有浏览器和版本中都不可靠。不鼓励使用非ISO日期格式,并将在即将发布的主要版本中将其删除。请参阅http://momentjs.com/guides/#/warnings/js-date/了解更多信息。参数:[0] _isAMomentObject:true,_isUTC:true,_useUTC:true,_l:未定义,_i:2016-9-26 19:30,_f:未定义,_strict:未定义,_locale:[对象Object]
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);
});
moment.tz('2016-9-28 20:30', 'YYYY-M-D H:mm', 'Pacific/Auckland');
根据说明进行操作 ...这将接受1或2位数的月份和天数,以及24小时格式的1或2位数的小时数
'2016-9-26 19:30'
并不是公认的ISO格式