How to convert from UTC to local time in moment.js?

前端 未结 1 514
你的背包
你的背包 2020-12-15 23:50

I have a simple use case but I cannot figure out how to convert from GMT/UTC to local time in moment.js.

Example:

var gmtDateTime = moment.utc(\"20         


        
相关标签:
1条回答
  • 2020-12-16 00:22

    Try moment().local().

    Example:

    var gmtDateTime = moment.utc("2015-10-24 20:00", "YYYY-MM-DD HH")
    var local = gmtDateTime.local().format('YYYY-MMM-DD h:mm A');
    
    0 讨论(0)
提交回复
热议问题