Javascript: Getting invalid Time Zone
I have found following piece of code for client time zone:
Code:
alert((new Date().getTimezoneOffset()/60) * -1)
It works fine for positive time zone. But when set negative time zone on system. I got one hour later e.g. if i set -8 time zone on system then i got -7.
ANY IDEA HOW CAN I RESOLVE IT?
Re: Javascript: Getting invalid Time Zone
getTimezoneOffset only gets hoe many hours you are off of GMT. It will never produce a negative. If you know that you are in need of a negative just use the following.
Code:
var d = new Date();
offsetGMT = -(d.getTimezoneOffset() / 60);
Re: Javascript: Getting invalid Time Zone
Ok i resolve the problem. It is showing me one hour difference because on my system "Automatically adjust clock for day light saving" is on.