moment.js 24h format

前端 未结 8 1012
無奈伤痛
無奈伤痛 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: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)

提交回复
热议问题