时刻,日期和日期时间 - 本地

时间:2015-07-25 14:14:07

标签: javascript jquery fullcalendar

我试图覆盖fullCalendar ClickEvent并将结束日期moment填入<input type="datetime-local"

$('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: false,
        droppable: true,
        //edit existing
        eventClick: function(calEvent, jsEvent, view) {
             var startDateString = calEvent.start.toDate().toISOString();
             $('#startDate').val(startDateString.replace('Z', '') );

我在对设置值(herehere

之后对[下面的代码片段]的确切内容进行了一些广泛的研究后,实施了上述内容。

<input type="datetime-local" name="startDate" id="startDate" class="ui-widget-content" style="width:100%"&GT;

但是由于时区而导致上述时间总是错误,因为即时通讯使用toDate()(请参阅here)。 示例:我点击一个事件,显示它从上午9:30开始,但输入框设置为下午2:30。我怎么可能形成我的日期,以便当它们出现在我的输入框中时,它们是相同的?

供参考:

我尝试只使用calEvent.start.format(),但我的输入不会接受它作为有效值(控件中没有设置任何内容,与下面显示结束日期的图像中的内容相同)。我相信这是因为而不是&#34; T&#34;将日期和时间分开是&#34; A&#34;或&#34; P&#34;分开它。

我尝试使用datetime(而不是datetime-local)但据我所知,这只是一个文本框。 datetime-local有箭头和分隔符。下图显示了差异,开始日期为datetime,结束日期为datetime-local

enter image description here

1 个答案:

答案 0 :(得分:0)

显示由我做的地方的cal事件:

    var technicianSchedule = {technician:technicians[Math.floor((Math.random() * technicians.length))] , start:datetimeStart , end:datetimeEnd, title: "Title "+i,description: "Desc "+i};
    technicianSchedules.push(technicianSchedule);

我需要在日期对象上调用.toLocaleString()来删除时区内容

    var technicianSchedule = {technician:technicians[Math.floor((Math.random() * technicians.length))] , start:datetimeStart.toLocaleString() , end:datetimeEnd.toLocaleString(), title: "Title "+i,description: "Desc "+i};
    technicianSchedules.push(technicianSchedule);