使用 Moment.js 版本 2.0.0+ 转换位置之间的特定日期和时间

Ude*_*esh 1 timezone date momentjs

如何使用 Moment.js 2.0.0+ 将表示纽约、纽约日期和时间的日期时间字符串更改为澳大利亚墨尔本?


我在 StackOverflow 上找到的其他答案已经过时或与我的用例略有不同。

convert this string '2016-04-28 09:30:00' to its Melbourne Australia equivalent 
Run Code Online (Sandbox Code Playgroud)

Mat*_*int 5

简单地:

var s = moment.tz('2016-04-28 09:30:00',      // input date time string
                  'YYYY-MM-DD HH:mm:ss',      // format of input
                  'America/New_York')         // time zone of input

              .tz('Australia/Melbourne')      // convert to another time zone

              .format('YYYY-MM-DD HH:mm:ss'); // format output string
Run Code Online (Sandbox Code Playgroud)