【问题标题】:How to make the events in fullCalendar display in 12H not 24H format如何使全日历中的事件以 12 小时而不是 24 小时格式显示
【发布时间】:2019-07-21 07:35:45
【问题描述】:

我有一堆日历都来自一个网站上的谷歌日历,除了以 24 小时格式显示的事件之外,一切都很好。

我尝试在 jQuery 代码中设置它,但我无法找出正确的代码来执行此操作。在 Google 日历设置中,它们都设置为 12H,因此它必须是 fullCalendar

这是我进行搜索时唯一能找到的代码,但它似乎没有做任何事情:

$(function() {
  $('#calendar').fullCalendar({
    header: {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    },
    timeFormat: 'h(:mm)t',
    timezone: 'America/Toronto',
    googleCalendarApiKey: 'hidden',
    eventSources: [{
      googleCalendarId: 'hidden',
      className: 'calendar'
    }]
  });
});

timeFormat 是控制它的正确线路吗?

谢谢!

【问题讨论】:

    标签: jquery fullcalendar time-format


    【解决方案1】:

    timeFormat 选项设置正确。

    现在你需要consult the momentJS documentation(链接到这个fullCalendar documentation(又链接到timeFormat documentation))来知道你可以使用什么格式的字符串来获得你想要的格式显示的时间。

    例如:

    timeFormat: "HH:mm"
    

    将为您提供 24 小时的时间,例如 21:00 等。如果您需要它以显示稍有不同的内容,您可以自行修改。

    演示:http://jsfiddle.net/8bx14goh/

    【讨论】:

      猜你喜欢
      • 2014-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-15
      • 2013-11-29
      相关资源
      最近更新 更多