Struggling with converting a UTC Date string with an offset to the user's local time accurately. When a date like 2017-06-21T20:26:28.744Z
comes from our server, the goal is to turn it into a timestamp of the sender's local time, factoring in a 6-hour offset.
Realizing that relying solely on the "Z" portion may not be correct.
The task is to transform 2017-06-21T20:26:28.744Z
into 2017-06-21T14:26:28
using moment.js.
While attempting this, the result is the UTC part of the string without considering the offset. It's crucial to utilize the offset to adjust the hours and minutes accordingly.
moment
.utc('2017-06-21T20:26:28.744Z')
.local()
.format('YYYY-MM-DDTHH:mm:ss')
// Output: 2017-06-21T20:26:28"
// Desired: 2017-06-21T14:26:28