EndenDragon EndenDragon - 5 months ago 6x
Javascript Question

How do I get the current timezone offset (and formatted it properly)?

How would I use javascript to format the computer's timezone offset to this format:

, as in
(America/Los_Angeles) for example.


getTimezoneOffset returns a Number representing the time difference between UTC and Local Time, in minutes

var date = new Date();
var tzOffset = date.getTimezoneOffset();
var hours = ~~(tzOffset / 60);
var minutes = Math.abs(tzOffset % 60);
alert('Hours: ' + hours + ' Minutes: ' + minutes);