Moment.js Convert Local time to UTC time does work

后端 未结 7 1922
伪装坚强ぢ
伪装坚强ぢ 2021-01-01 18:23

I would like to use Moment.js to convert a local time to UTC equivalent. I believe that I have the correct method in place, but it does not alter the time.

I\'m in S

7条回答
  •  臣服心动
    2021-01-01 18:48

    I just tried this code and it seems like I get the correct UTC time. I guess I just want to confirm that what I am doing is correct way to access the UTC time from moment.js

    a.format("YYYY-MM-DD HH:mm:ssZ")
    

    I found that my usage pattern of in my application was incorrect

    selectedDate.utc().format(fullFormat)
    

    It should have been

    moment.utc(selectedDate).format(fullFormat)
    

提交回复
热议问题