Scenario
I have a UTC date in string format and an associated offset number in minutes:
- Date: "2017-10-01T12:00:00.000Z"
- Offset: 360
The user's browser is in the Mountain Standard Time (-7) timezone. The date value was recorded from the Central Standard Time (-6) timezone, and was saved along with its offset (hence the offset of 360 minutes). It can be assumed the offset does not include for daylight savings time.
Question
How do I parse the UTC date using the offset for the timezone it was recorded in? In other words, despite the user's browser being MST, I still want to display the date in a string as something like "2017-10-01 6:00 AM". Displaying the timezone is not required. Is this possible using moment-timezone without having the name of the timezone and just having the offset that doesn't include DST?
Is that what you need ?
here you'll find a lot of displaying options -> http://momentjs.com/docs/#/displaying/
or maybe just:
I guess that the timestamp "2017-10-01T12:00:00.000Z" is correct and that the offset of 360 is really -360 (since you say it should really be US Central Standard Time of -0600).
Offsets never consider daylight saving, they are absolute values. Daylight saving changes the offset for a region within a timezone, usually reflected by also changing the timezone name (e.g. Central Standard Time to Central Daylight Time).
Anyway, if the original value is always UTC and you want to display it in the original timezone, you can parse the original UTC date to a Date, adjust the UTC time value, then use toISOString (which is always UTC) and append the appropriate offset designator. You also have to flip the sign of the offset.
The following does all that and avoids the built-in parser, don't be tempted to use it: