How to ISO 8601 format a Date with Timezone Offset in JavaScript?

前端 未结 11 1696
时光说笑
时光说笑 2020-11-22 09:32

Goal: Find the local time and UTC time offset then construct the URL in following format.

Example URL: /Actions/Sleep?dura

11条回答
  •  鱼传尺愫
    2020-11-22 09:36

    Just my two sends here

    I was facing this issue with datetimes so what I did is this:

    const moment = require('moment-timezone')
    
    const date = moment.tz('America/Bogota').format()
    

    Then save date to db to be able to compare it from some query.


    To install moment-timezone

    npm i moment-timezone
    

提交回复
热议问题