Format time.js 24h

How to display my time in 24h instead of 12?

I am using moment.js.

I am sure that these lines may 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?

+103
javascript momentjs
Oct 19
source share
4 answers

Have you read the docs ?

It indicates

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

Thus, specifying your time as HH , you will get a 24-hour format, and HH will provide a 12-hour format.

+314
19 Oct.
source share

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

+28
Oct 19 '12 at 8:45
source share
+11
Oct 19 '12 at 8:37
source share

moment ("01:15:00 PM", "h: mm: ss A"). format ("HH: mm: ss") ** o / p: 13:15:00 ** it will convert the format 24 hours to 12 hours.

+9
Oct 12 '17 at 9:58 on
source share



All Articles