EndenDragon EndenDragon - 2 years ago 66
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.

Answer Source

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);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download