formatTime用“h”代替“:”作为分隔符 [英] formatTime with “h” instead of “:” as separator

查看:85
本文介绍了formatTime用“h”代替“:”作为分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我想在FullCalendar的timeFormat选项中添加h字符。在法国,我们使用以下24小时格式的时间:18h30。 2.
我在这里找到了一个较旧的帖子:
formatTime与h而不是:作为分隔符
,但解决方案显然不再适用于FullCalendar v2。



有没有办法让我逃避h字符在timeFormat选项?

解决方案

Fullcalendar使用 Moment.js 日期/时间。

转义字符:


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


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


这适用于 formatTime fullcalendar选项:

  timeFormat:'H [h](mm)'

演示JSFiddle


In France, we use the following 24 hour format for time: 18h30.

Therefore, I want to add the "h" char in the timeFormat option of FullCalendar 2. I found an older post here: formatTime with "h" instead of ":" as separator but the solution is apparently not working anymore with FullCalendar v2.

Is there a way I could "escape" the "h" character in the timeFormat option ?

解决方案

Fullcalendar uses Moment.js for date/times.

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)'

Demo JSFiddle

这篇关于formatTime用“h”代替“:”作为分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆