I would like to be able to display time based on the user’s current time zone. I will be storing times in UTC format in my database, but wish to normalize these to the client’s time zone. So far the option that seems most viable is to capture the clients time and then deteremine the difference between that and current UTC and use that delta to normalize times when rendering. I would like to know if there are any more straight forward options available to detect and normalize a UTC time to that of the requesting client’s machine.
Share
I would use the javascript dateObject.getTimezoneOffset(). Even if their time isn’t set accurately, hopefully they’ve set their timezone:
You can use this value to calculate an offset between the server’s time and the client’s time. (as Jason helpfully pointed out in a comment below)