使用Moment.js版本2.0.0+转换位置之间的特定日期和时间(Convert a specific date and time between locations using Moment.js version 2.0.0+)
如何使用Moment.js 2.0.0+将代表纽约,纽约日期和时间的日期时间字符串更改为澳大利亚墨尔本?
我在StackOverflow上找到的其他答案已经过时或与我的用例略有不同。
convert this string '2016-04-28 09:30:00' to its Melbourne Australia equivalentHow do I change a date time string that represents a New York, New York date and time to Melbourne Australia using Moment.js 2.0.0+ ?
Other answers I found on StackOverflow were outdated or slightly different than my use case.
convert this string '2016-04-28 09:30:00' to its Melbourne Australia equivalent最满意答案
只是:
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 stringSimply:
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更多推荐
发布评论