formatTime以“h”而不是“:”作为分隔符

我们在葡萄牙使用以下24小时格式: 18h3018h30 。 我试过了:

 timeFormat: 'H'h'(mm)' timeFormat: {'H'h'(mm)'} timeFormat: 'H\h(mm)' 

可能吗? 谢谢。

您需要在javascript字符串中使用单引号将字母h作为文字文本插入。 最简单的方法是使用双引号作为字符串分隔符,如:

 timeFormat: "H'h'(mm)" 

作为参考,如果要在单引号字符串中使用单引号,请对每个引号使用转义,如下所示:

 timeFormat: 'H\'h\'(mm)' 

这里报告了一个最新的解决方案,适用于FullCalendar2: formatTime,其中“h”代替“:”作为分隔符

逃脱角色:

要转义格式字符串中的字符,可以将字符包装在方括号中。

 moment().format('[today] dddd'); // 'today Sunday' 

这也适用于formatTime fullcalendar选项:

 timeFormat: 'H[h](mm)'