2015-09-21 280 views
3

我正在查看官方FullCalendar網站的debug page。我想安排從2015年9月22日至2015年9月30日的活動(年/月/日)。但它僅在2015年9月22日至2015年9月29日 - 2015年9月30日缺失的日期顯示。fullCalendar未顯示正確的結束日期

下面是代碼:

$(function() { // document ready 
    $('#calendar').fullCalendar({ 
    header: { 
     left: 'prev,next today', 
     center: 'title', 
     right: 'month,agendaWeek,agendaDay' 
    }, 
    defaultDate: '2014-11-12', 
    editable: true, 
    eventLimit: true, // allow "more" link when too many events 
    events: [ 
     { 
      title: 'Meeting', 
      start: '2015-09-22', 
      end: '2015-09-30' 
     } 
    ] 
    }); 
}); 

下面是輸出的圖像:

enter image description here

這有什麼代碼問題?

+0

[*這是活動結束後,立即時刻。例如,如果活動的最後一天是星期四,則活動的專用結束時間爲星期五的00:00:00!*](http://fullcalendar.io/docs/event_data/Event_Object/) – D4V1D

回答

2

不要將日期視爲離散的日子,而應將其視爲時間上的連續。日期2015-09-30隱含給出時間00:00:00,即午夜。這意味着該活動實際上不會延續至第30天,而是在該日開始時。

這給你一個簡單的解決方案。僅僅一天後結束事件:

end: '2015-10-01' 

或者,把它從documentation

這是活動結束後,立即時刻。例如,如果活動的最後一天是星期四,則活動的專用結束時間爲星期五的00:00:00!

+0

這適用於整天,但不適用於部分日期。我現在這個嘗試:事件:[{ 標題 : '會議', 開始: '2015-09-08T02:30:00', 結束: '2015-09-09T04:30:00' } ]並沒有顯示日期2015-09-09只顯示:2015-09-08。可能是什麼問題? – Dushy

+0

確定發現部分日期有問題。只需添加nextDayThreshold:'00:00:00', – Dushy

+1

@Dushy如果您找到了替代解決方案,則應將其作爲您自己問題的答案發布。 – Anders

0

確定以顯示正確的結束時間做到這一點:

整天像:從23-09-2015至30-09-2015(DD-MM-YYYY)
添加一天「結束」

$('#calendar').fullCalendar({  
    events: [ 
    { 
     title: 'Meeting', 
     start: '2015-23-09', 
     end: '2015-01-10' 
    } 
    ] 
} 

爲MySQL查詢添加這樣的日子:

DATE_ADD(end_date, INTERVAL 1 DAY) 

對於像一個一天的部分:從23-09-2015 12:00:0 0至30-09-2015 15:30:00(DD-MM-YYYY HH:MM:SS)
您需要設置fullcalendar 「nextDayThreshold」 paremeter所以它會從00:00

$('#calendar').fullCalendar({  
    nextDayThreshold:'00:00:00', 
    events: [ 
    { 
     title: 'Meeting', 
     start: '2015-23-09T12:00:00', 
     end: '2015-30-09T15:30:00' 
    } 
    ] 
} 
開始新的一天
+0

當我爲angular 5實現完整日曆時面臨同樣的問題,我會嘗試您的解決方案,但它不起作用,您可以幫助 – Kansara

0

您可以嘗試使用date_add()。

$date=date_create("2013-03-15"); 
date_add($date,date_interval_create_from_date_string("1 day")); 

然後應用php回顯新的日期。

end: '<?php echo date_format($date,"Y-m-d"); ?>' 
0

嘗試

$('#calendar').fullCalendar({ 
     nextDayThreshold:'00:00', // not 00:00:00 
    [...] 
0

enter image description here只需添加時間範圍12:00:00到24:00:00

events: [ 
    { 
     title: 'Anniversary', 
     start: '2018-01-21T12:00:00', 
     end: '2018-01-23T24:00:00' 
    } 
    ]