moment timezone adjust timestamp to a timezone and return value

十年热恋 提交于 2019-12-02 10:19:51

It looks like your timestamp values are strings that contain Unix Time values, in terms of seconds. You can parse them with the X format specifier in moment.

However, you cannot get a timestamp in this format that is adjusted for a time zone. That is because Unix Time values are always based on UTC. It is nonsensical for them to be in a time zone. Any such value would be in error.

You can however emit a string-based format, such as ISO 8601 - which is the default when you don't supply any arguments to the format function.

In short:

moment.tz('1528063200', 'X', 'Europe/Berlin').format() //=> '2018-06-04T00:00:00+02:00'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!