moment.js 24h format

前端 未结 8 963
無奈伤痛
無奈伤痛 2020-12-01 09:04

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.

<         


        
相关标签:
8条回答
  • 2020-12-01 09:33

    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)
    
    0 讨论(0)
  • 2020-12-01 09:36

    //Format 24H use HH:mm
    let currentDate = moment().format('YYYY-MM-DD HH:mm')
    console.log(currentDate)
    
    //example of current time with defined Time zone +1
    let currentDateTm = moment().utcOffset('+0100').format('YYYY-MM-DD HH:mm')
    console.log(currentDateTm)
    <script src="https://momentjs.com/downloads/moment.js"></script>

    0 讨论(0)
提交回复
热议问题