After receiving JSON data from an ASP.NET WebAPI2 service, I noticed that the dates are stored in UTC format. However, when displayed on screen using moment.js, the time is incorrect as it assumes the date is local time.
{
creationDate: "2014-11-18T15:16:56.363"
... //other fields...
}
When I try to parse the date with a specific time zone like 'Africa/Johannesburg', the time values end up being two hours behind instead of the current time. How can I properly parse and pass the date so that moment.js recognizes it as GMT+2 or SAST?
Simply adding 'UTC' to the date string doesn't seem to help, as shown in the example below:
Date.parse('2017-04-15T09:09:48.9590011 UTC')
This results in NaN
, indicating that the parsing was not successful.