fullCalendar的24小时时间格式(因此没有AM到PM)

我正在尝试在fullCalendar中显示24小时时间格式,我正在尝试使用这些说明: http ://arshaw.com/fullcalendar/docs/text/timeFormat/

所以我补充道

timeFormat: { agenda: 'H(:mm)' //h:mm{ - h:mm}' }, 

到json.php:

 $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, editable: true, allDayDefault: false, events: "core/displays/calendar/json-events.php", defaultView: 'agendaDay', timeFormat: { agenda: 'H(:mm)' //h:mm{ - h:mm}' }, eventDrop: function(event, delta) { alert(event.title + ' was moved ' + delta + ' days\n' + '(should probably update your database)'); }, eventClick: function(calEvent, jsEvent, view) { window.location = "details_view.php?id=" + calEvent.id; }, loading: function(bool) { if (bool) $('#loading').show(); else $('#loading').hide(); } }); }); 

但这没用,所以我添加到fullCalendar.js

 // time formats titleFormat: { month: 'MMMM yyyy', week: "MMM d[ yyyy]{ '—'[ MMM] d yyyy}", day: 'dddd, MMM d, yyyy' }, columnFormat: { month: 'ddd', week: 'ddd M/d', day: 'dddd M/d' }, axisFormat: 'H(:mm)', //,'h(:mm)tt', timeFormat: { agenda: 'H(:mm)' //h:mm{ - h:mm}' }, // locale 

但这也不起作用,我做错了什么?

您希望将布局设置为24小时制或事件。

如果你想添加到事件,请像22:00’party’那样将timeFormat:’H:mm’添加到你的json.php文件中。

 eventDrop: function (event, delta) { alert(event.title + ' was moved ' + delta + ' days\n' + '(should probably update your database)'); }, timeFormat: 'H:mm', 

如果您想更改日历的布局,请转到fullCalendar.js

抬头:

setDefaults

并改变您的代码,如下所示。

 setDefaults({ allDaySlot: true, allDayText: 'Volledige dag', firstHour: 8, slotMinutes: 30, defaultEventMinutes: 120, axisFormat: 'HH:mm', timeFormat: { agenda: 'H:mm{ - h:mm}' }, dragOpacity: { agenda: .5 }, minTime: 0, maxTime: 24 }); 

此选项现在适用于fullCalendar v2:

 slotLabelFormat:"HH:mm" 

http://fullcalendar.io/docs/agenda/slotLabelFormat/

如果你想在24小时搜索中更改月视图并在fullcalendar.js中更改:

 var dateFormatters = { s : function(d) { return d.getSeconds() }, ss : function(d) { return zeroPad(d.getSeconds()) }, m : function(d) { return d.getMinutes() }, mm : function(d) { return zeroPad(d.getMinutes()) }, h : function(d) { return d.getHours() % 24 || 24 }, //modificato : era 12 al posto di 24 hh : function(d) { return zeroPad(d.getHours() % 24 || 24) }, //modificato : era 12 al posto di 24 H : function(d) { return d.getHours() }, HH : function(d) { return zeroPad(d.getHours()) }, d : function(d) { return d.getDate() }, dd : function(d) { return zeroPad(d.getDate()) }, ddd : function(d,o) { return o.dayNamesShort[d.getDay()] }, dddd: function(d,o) { return o.dayNames[d.getDay()] }, M : function(d) { return d.getMonth() + 1 }, MM : function(d) { return zeroPad(d.getMonth() + 1) }, MMM : function(d,o) { return o.monthNamesShort[d.getMonth()] }, MMMM: function(d,o) { return o.monthNames[d.getMonth()] }, yy : function(d) { return (d.getFullYear()+'').substring(2) }, yyyy: function(d) { return d.getFullYear() }, //t : function(d) { return d.getHours() < 12 ? 'a' : 'p' }, //tt : function(d) { return d.getHours() < 12 ? 'am' : 'pm' }, //T : function(d) { return d.getHours() < 12 ? 'A' : 'P' }, //TT : function(d) { return d.getHours() < 12 ? 'AM' : 'PM' }, t : function(d) { return d.getMinutes() == 0 ? ':00' : '' }, tt : function(d) { return d.getHours() < 12 ? '' : '' }, T : function(d) { return d.getHours() < 12 ? '' : '' }, TT : function(d) { return d.getHours() < 12 ? '' : '' }, u : function(d) { return formatDate(d, "yyyy-MM-dd'T'HH:mm:ss'Z'") }, S : function(d) { var date = d.getDate(); if (date > 10 && date < 20) { return 'th'; } return ['st', 'nd', 'rd'][date%10-1] || 'th'; } 

};

如果您使用的是fullCalendar v1,则应尝试添加以下内容:

 $('#calendar').fullCalendar({ [...]// some code, axisFormat: 'H:mm', timeFormat: { agenda: 'H:mm{ - H:mm}' } }); 

出于某种原因,这些解决方案对我不起作用了。

所以经过一些广泛的(cmd + F)搜索,我发现这篇文章在第107行左右谈论/includes/js/main.js。第107行允许你更改日/月/年订单。

但是之后! 第113行(或周围)允许您将星期和日期议程视图中的上午/下午更改为全世界使用的时间表示(一些英语国家除外)。

如果你愿意,你可以更改更多,但在下面你会发现足够好的片段代码让我在荷兰网站上正确显示它。

TT:function(a){return a.getHours()<12?"AM":"PM"},u:function(a){return Oa(a,"yyyy-MM-dd'T'HH:mm:ss'Z'")},S:function(a){a=a.getDate();if(a>10&&a<20)return"th";return["st","nd","rd"][a%10-1]||"th"}};Aa.applyAll=$a;Ja.month=mc;Ja.basicWeek=nc;Ja.basicDay=oc;wb({weekMode:"fixed"});Ja.agendaWeek=qc;Ja.agendaDay=rc;wb({allDaySlot:true,allDayText:"hele dag",firstHour:8,slotMinutes:30,defaultEventMinutes:120,axisFormat:"HH:mm",timeFormat:{agenda:"h:mm{ - h:mm}"},dragOpacity:{agenda:0.5},minTime:0, maxTime:22})})为了您的方便,您可以在这里找到整个main.js固定的荷兰语: http : //pastebin.com/HYGHRebZ

我希望这个解决方案也适合你!

用于v.2加上timeFormat: 'H(:mm)',

最受欢迎的答案适用于旧版本。 对于较新版本,在SetDefaults添加另一个变量:

 slotLabelFormat:'H(:mm)', 

这适用于较新版本(2018),如FullCalendar v3.9.0

 axisFormat: 'H:mm', timeFormat: { agenda: 'H:mm' }, 

它正在使用agendaDay视图和事件显示24小时格式