Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

moment.js 24h format

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)

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


moment("01:15:00 PM", "h:mm:ss A").format("HH:mm:ss")
**o/p: 13:15:00 **

It will convert 12hrs format to 24hrs format.


Use H or HH instead of hh. See http://momentjs.com/docs/#/parsing/string-format/


You can use

 moment("15", "hh").format('LT') 

to convert the time to 12 hours format like this 3:00 PM


HH used 24 hour format while hh used for 12 format