The server sends me a time-stamp in milliseconds (Unix time / time from Epoch) with the constant timezone "America/New_York". On my client side, I want to ensure that the time is displayed according to the America/New_York timezone. I have been using Joda-time and relying on the MDN Date documentation to instantiate Date objects using the new Date(milliseconds) constructor.
Now comes the challenge: I need to display the time for clients located outside the America/New_York timezone. I am aware of the getTimezoneOffset function in JavaScript Date objects, so I am considering performing arithmetic based on the offset and checking with the server for DST information using a method from the Joda Time library.
I would like a solution that is compatible with IE8 and modern browsers alike. Are there any existing utilities that can handle this in a standardized manner?
// dateTimeAsString is received as a String via JSON from the server
// Example of dateTimeAsString: "1311387300000"
var dateTimeAsInt = parseInt(dateTimeAsString, 10);
var dateTimeInNY = new Date(dateTimeAsInt);
// Current offset is 240 minutes
var nyOffset = dateTimeInNY.getTimezoneOffset();
// Somewhere in Texas
var dateTimeInTexas = new Date(dateTimeAsInt);
var isDST = false; // Information received from server
// Desired functionality (not valid JavaScript syntax)
dateTimeInTexas.printWithOffset(isDST, nyOffset);