I'm currently writing a small messaging app for global usage. I'm going to store the UTC timestamp of the message. I need to display the message to the user using AJAX, so i need to convert the UNIX timestamp to the users local time. I know how to get the timezone offset, but i'm afraid that it will be a little bit inaccurate and i need accuracy even in seconds (to display times like: 34 seconds ago). Which is the most accurate way to solve this?
-
My first tough was to compare the Date() and getUTC() values to calculate offset. Don't really know if that would be apporate.wintercounter– wintercounter2014-01-21 13:40:57 +00:00Commented Jan 21, 2014 at 13:40
-
var date = new Date(UTC+"000")mplungjan– mplungjan2014-01-21 13:41:28 +00:00Commented Jan 21, 2014 at 13:41
Add a comment
|