【问题标题】:Angular full calendar header date in the calendar is in the wrong format日历中的角度完整日历标题日期格式错误
【发布时间】:2021-12-31 00:50:34
【问题描述】:

如何获得完整日历角度的正确格式?它目前有月/日的格式,但我需要它是日/月

格式错误,应该是dd/mm

this.calendarOptions = {
  plugins: [ dayGridPlugin, timeGridPlugin, interactionPlugin],
  initialView: 'timeGridWeek',
  headerToolbar: {
    left: 'prev,next', 
    center: 'title', 
    right: 'dayGridMonth,timeGridWeek,timeGridDay'
  },
  firstDay: 1
};

【问题讨论】:

  • 你做了哪些研究?文档中有关于更改日期格式以及区域设置的信息。
  • 我查看了文档fullcalendar.io/docs/dayHeaderFormat 但是,它不适用于 angular,因为它基于 javascript,而我使用的是 angular typescript。
  • 所有 fullCalendar 选项都适用于角度,没有区别。即使您使用的是 typescript,它也会被转译为 JavaScript,因此您可以在 JavaScript 中表示的任何内容也可以在 typescript 中表示 - 通常使用完全相同的语法。如果您在尝试过的某些事情上遇到特定问题,请更新问题以提供问题的minimal reproducible example

标签: angular typescript fullcalendar


【解决方案1】:

下面的代码将其以正确的格式放入日历中,同时将其更改为 24 小时格式。

  locale: 'en-gb',
  slotLabelFormat: {
    hour: 'numeric',
    minute: 'numeric',
    hour12: false
  },

对于时间轴,有一个数组允许上面有 2 个插槽标签。

locale: 'en-gb',
  slotLabelFormat: [{
      weekday: 'short',
      day: 'numeric',
      month: 'numeric'
    },
    {
      hour: 'numeric',
      minute: 'numeric',
      hour12: false
    }
  ],

https://fullcalendar.io/docs/date-formatting

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-05
    • 1970-01-01
    • 2019-02-16
    • 2017-06-30
    • 1970-01-01
    • 1970-01-01
    • 2011-07-10
    • 1970-01-01
    相关资源
    最近更新 更多