How to put 0 in front of time? #1915
-
Hello, I'm using the calendar module with datetime and I would like to have times displayed with zero in front of time that are less than 10. Obviously, the same should happen to the time in the string that appears after the users pick date and time from calendar. Is it possible to do that? I have found this, but it seems not to be usefull in my case. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As mentioned in the linked post you can also modify the time formatter according to your needs, to time: function (date, settings, forCalendar) {
if (!date) {
return '';
}
var hour = date.getHours();
var minute = date.getMinutes();
var ampm = '';
if (settings.ampm) {
ampm = ' ' + (hour < 12 ? settings.text.am : settings.text.pm);
hour = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
}
return (hour < 10 ? '0':'') + hour + ':' + (minute < 10 ? '0' : '') + minute + ampm;
}, |
Beta Was this translation helpful? Give feedback.
-
Got it, thank you! |
Beta Was this translation helpful? Give feedback.
As mentioned in the linked post you can also modify the time formatter according to your needs, to
See https://jsfiddle.net/lubber/jpLru0ev/6/