formatTime with “h” instead of “:” as separator

女生的网名这么多〃 提交于 2019-12-12 10:08:51

问题


We use the following 24 hour format for time in Portugal: 18h30. I've tried:

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

Is it possible? Thank you.


回答1:


You need to use single quotes inside the javascript string to insert the letter h as literal text. The easiest way for this is to use double quotes as string delimiters, as in:

timeFormat: "H'h'(mm)"

For reference, if you want to use single quotes inside a single quoted string, use an escape for each quote, as in:

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



回答2:


An up-to-date solution is reported here and works for FullCalendar2: formatTime with “h” instead of “:” as separator

Escaping Characters:

To escape characters in format strings, you can wrap the characters in square brackets.

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

This works for the formatTime fullcalendar option too:

timeFormat: 'H[h](mm)'


来源:https://stackoverflow.com/questions/6176338/formattime-with-h-instead-of-as-separator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!