![](/img/trans.png)
[英]“Deprecation warning: moment construction falls back to js Date” when trying to convert RFC2822 date in moment.js
[英]Deprecation warning: moment construction falls back to js Date when I use moment.js to get current date
我使用moment.js獲取當前日期。 這是代碼:
$(document).ready(function() {
var date = moment().format("YYYY/MM/DD");
console.log(date);
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: date,
editable: true,
eventLimit: true // allow "more" link when too many event
});
});
我在控制台中獲得了當前日期以及以下警告:
Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.
所以我這樣添加了ISO標簽:
var date = moment().format("YYYY/MM/DD", "ddd, YYYY MM DD HH:mm:ss ZZ");
但是我得到了同樣的警告。 如何刪除此警告?
我上面的代碼沒有收到警告。 我能夠使用其他語法來引發警告:
// does not generate warning
var date1 = moment().format("YYYY/MM/DD");
console.log(date1);
// generates warning
var date2 = moment("YYYY/MM/DD");
console.log(date2);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.