moment.js 24h format


How do I display my time in 24h format instead of 12?

I am using moment.js.

I am pretty sure that these lines could have something to do with it.

   meridiem : function (hours, minutes, isLower) {
        if (hours > 11) {
            return isLower ? 'pm' : 'PM';
        } else {
            return isLower ? 'am' : 'AM';

How to change it?

This question is tagged with javascript momentjs

~ Asked on 2012-10-19 08:31:49

The Best Answer is


Stating your time as HH will give you 24h format, and hh will give 12h format.

You can also find it here in the documentation :

    H, HH       24 hour time
    h, or hh    12 hour time (use in conjunction with a or A)

~ Answered on 2012-10-19 08:38:23


Try: moment({ // Options here }).format('HHmm'). That should give you the time in a 24 hour format.

~ Answered on 2012-10-19 08:45:43

Most Viewed Questions: