formatTime与“;h〃;而不是“:"作为分离器

formatTime with "h" instead of ":" as separator

本文关键字:quot 分离器 formatTime      更新时间:2023-09-26

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

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完整日历选项:

timeFormat: 'H[h](mm)'