momentjs toDate() - timezone gets reset

后端 未结 3 546
长发绾君心
长发绾君心 2021-02-13 22:12

I am working with momentjs and converting dates to different time zones using convertedDate = moment().utcOffset(timezone).format(). This works well but it is a str

3条回答
  •  孤独总比滥情好
    2021-02-13 22:30

    So I wasn't very far off. The format needs to exclude timezone for it to work. This code finally worked how I needed it to.

    convertedDate = new Date(moment().utcOffset('-4').format('YYYY-MM-DD HH:mm'));

提交回复
热议问题