I see an excellent summary of handling time in webapp here. But, it doesn't clearly address the below scenario. I wanted a way to get the local time in web application based on date time at UTC + Location(iana timezone location - America/New_York).
I am looking for a library which does the following calculation. If it works natively in Javascript, that also suit my purpose.
From server, following information is retrieved
{
dateTime: "2002-10-27T15:04:05Z" # Time in UTC, no TimeZone info
userTimeZone: "America/New_York" # based on current user location
}
The issue is that, I couldn't find a way to convert it to the time at location (New York) considering daylight savings offset.
I am not sure saving time zone offset in database solve the issue as my user may be from across region and may look at the same data. For example, the event happened at a location belongs to Estern zone (EST/EDT), but the user at Pacific zone may query the data based on their location (8AM - 5PM "America/Los_Angeles" - PST/PDT).
I looked at Moment.js, but couldn't find a solution.
To summarize, I need a way to get the local time at a specific location(considering daylight savings offset) in web browser, from an input of date time at UTC + IANA location.