moment-timezone
moment-timezone copied to clipboard
This make no sense: moment(date).tz('UTC') ≠moment.tz(date,'UTC')
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
@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..
old issue, but to clarify if anyone looking:
moment('2018-01-01').tz('UTC').format('MM DD, YYYY') // 31 12, 2017
Creates a new date in current system timezone and then convert it to UTC (results may differ depending on current timezone)
moment.tz('2018-01-01', 'UTC').format('MM DD, YYYY') // 01 01, 2018
Creates a new date in UTC timezone.