0
我使用了moment.js獲取當前日期。下面是代碼:棄用警告:時刻建設回落到js使用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");
但我得到了同樣的警告。我如何刪除此警告?
你確定這是導致警告的行:我使用不同的語法,能夠誘導警告?我認爲警告來自解析日期字符串,而不是格式化。 – Barmar
我在編輯問題並添加完整的代碼.... –
什麼是'fullCalendar()'?你確定問題不是由此造成的嗎?因爲你調用'moment()'的方式不會產生這個錯誤。什麼是首先被記錄的:你的'console.log()',或棄用警告? – robertklep