问题
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 ?
回答1:
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
回答2:
You cannot escape it, however you can use the eventRender
method to do the trick for you.
When the event is being rendered parse the DOM and replace the occurrence of : with h.
timeFormat: "H:mm",
eventRender: function(event, element) {
element.find('.fc-time').text(function () {
return $(this).text().replace(":", "h");
});
}
来源:https://stackoverflow.com/questions/28127435/formattime-with-h-instead-of-as-separator