|
-
July 28th, 2008, 04:59 AM
#1
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?
Muhammad Waqas Badar
-
July 28th, 2008, 09:06 AM
#2
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);
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
July 29th, 2008, 01:30 AM
#3
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.
Muhammad Waqas Badar
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|