I am looking for a function to convert date in one timezone to another.
(我正在寻找将一个时区中的日期转换为另一个时区的函数。)
It need two parameters,
(它需要两个参数,)
(日期(格式为“ 2012/04/10 10:10:30 +0000”))
(时区字符串(“亚洲/雅加达”))
The timezone string is described in http://en.wikipedia.org/wiki/Zone.tab
(时区字符串在http://en.wikipedia.org/wiki/Zone.tab中进行了描述)
Is there an easy way to do this?
(是否有捷径可寻?)
For moment.js users, you can now use moment-timezone .
(对于moment.js用户,您现在可以使用moment-timezone 。)
(使用它,您的函数将如下所示:)
function toTimeZone(time, zone) { var format = 'YYYY/MM/DD HH:mm:ss ZZ'; return moment(time, format).tz(zone).format(format); }
1.4m articles
1.4m replys
5 comments
57.0k users