Moment-timezone: This make no sense: moment(date).tz('UTC') 鈮爉oment.tz(date,'UTC')

Created on 20 Apr 2018  路  2Comments  路  Source: moment/moment-timezone

Description

These are not equal. It makes no sense.

moment('2018-01-01').tz('UTC').format('MM DD, YYYY') // 31 12, 2017
moment.tz('2018-01-01', 'UTC').format('MM DD, YYYY') // 01 01, 2018

Environment

Firefox Quantum 59.0.2 on Windows 10

Most helpful comment

@Ohar
It works according to the documentation https://momentjs.com/timezone/docs/#/using-timezones/

moment.tz(..., String) is used to create a moment with a time zone,
moment().tz(String) is used to change the time zone on an existing moment

But I agree that it's very confusing - looks similar, but works in a different way.

All 2 comments

@Ohar
It works according to the documentation https://momentjs.com/timezone/docs/#/using-timezones/

moment.tz(..., String) is used to create a moment with a time zone,
moment().tz(String) is used to change the time zone on an existing moment

But I agree that it's very confusing - looks similar, but works in a different way.

They have the same result for me..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  4Comments

LunarSweeper picture LunarSweeper  路  4Comments

rama41222 picture rama41222  路  3Comments

sbrandwoo picture sbrandwoo  路  4Comments

mj1856 picture mj1856  路  5Comments