CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Posts
    49

    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

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    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.

  3. #3
    Join Date
    Nov 2005
    Posts
    49

    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
  •  





Click Here to Expand Forum to Full Width

Featured