【发布时间】:2015-02-04 04:55:33
【问题描述】:
moment.js 有一个奇怪的问题。我编写了一个函数来将时间从 utc 转换为德国时间格式,并且在 chrome 中一切似乎都运行良好。但现在我用 Firefox 试了一下,发现日期无效。
moment.locale("de");
$('#from').datepicker({
format: "DD. MMMM YYYY"
});
$('#from').on('change',function() {
var a = moment($('#from').val(), "DD. MMMM YYYY").format("LLLL");
var b = moment(a).add(7,'days');
var localTime = moment.utc(b).toDate();
localTime = moment(localTime).format('DD. MMMM YYYY');
$('#to').val(localTime);
});
$('#to').datepicker({
format:'DD.MMMM YYYY'
});
$('#sendbtn').on('click',function(){
/...
var from = moment(fromfield.value).format();
var to = moment(tofield.value).format();
/...
$('#calendar').fullCalendar( 'gotoDate', from );
getEventDate(from,to,persons.value);
}
});
function getEventDate(start,end,people) {
var Calendar = $('#calendar');
Calendar.fullCalendar();
var Event = {
title:"Your stay for "+people+" people",
allDay: true,
start: start,
end: end
};
filljson(start,end,people);
Calendar.fullCalendar( 'renderEvent', Event );
}
/ ...
我已经看到了这个answer,但无论哪种方式都无法让它工作。有人可以帮帮我吗?
【问题讨论】:
标签: javascript jquery google-chrome firefox momentjs