Same date in different time zone

前端 未结 4 2090
小鲜肉
小鲜肉 2020-12-02 17:18

My question is how can I get the same day, month, year, hour, minutes, seconds in a different time zone, for example:

var now = moment().valueOf();
var resul         


        
4条回答
  •  -上瘾入骨i
    2020-12-02 17:44

    After reading the above comments, I thought I'd add in based on Joao's answer. In my case I was trying to use a preexisting moment date with a timezone and converting it to another timezone while retaining the original date value (as asked in the question).

    var newTimezone = 'America/Denver';
    
    //date - contains existing moment with timezone i.e 'America/New_York'
    moment.tz(date.format('YYYY-MM-DDTHH:mm:ss'), 'YYYY-MM-DDTHH:mm:ss', newTimezone);
    

提交回复
热议问题