SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Resource

Localizing time-based information

Categories...
Client User Group
Write Once!
Language
JavaScript, VBScript
Product
IE3, IE4, IE5, IIS, NS3, NS4
Server User Group
Active Server Pages
Task
Cross-Browser DHTML, Layout Enhancement, Site Design, Timers
Technology
ECMA-262, Server Scripting

Sponsored Links
Developer's Paradise : Inside Technique :
Localizing time-based information
Submission by SiteExperts Staff

Go to the resource:
Localizing time-based information

Add to Assistant

Short Description
Using javascript, ASP, and cookie wizardry you can present time-based data in your user's timezone.

Long Description
A great way to improve your site is to personalize your time and date based information for your user's timezone. We show you how with a little cookie, JavaScript, and ASP wizardry.

Author
Scott Isaacs
Date/ Version
3/23/2000
Submission URL
http://www.SiteExperts.com/tips/functions/ts22/timing.asp
Submission Date
Mar 23,2000
Last Update
Mar 23,2000
 

Discussion and Rate this Resource
Overall Rating: 3.5

sachingedam on Aug 1, 2006 at 3:52:18 AMNo Rating

Its good and easy solution for getting TimeZone information. But I would like to show u one problem in this tech.

If I store information in two array one will hold timezone abbrivation and other GMT offset and if I try to findout timezone based on GMT offset then it could be problamatic.

Lets take this three time zone

AZ,-420
MXB,-420

MXD,-420

These three time zone represent different different time zone but in this also MXB have daylight saving , and if i search timezone array than i will get AZ as first element and could not get expectd result.

So can you please give me solution over this?

k1mgy on Apr 3, 2005 at 7:43:56 PMRating: 2
On the page: http://www.siteexperts.com/tips/functions/ts22/timing.asp regarding "Localizing time-based information", the time that your server is reporting is:

4/3/2005 7:33:56 PM PST
But the actual time when I ran this test was 22:24:45 PST.

So it appears that your server clock is incorrect by a little more than 9 minutes.

Also, I am in the Eastern zone and we just shifted to DST. When I reload the page (mozilla or IE) I get 4/3/2005 11:35:27 PM which is one hour ahead of the current time.

Something seems broken with your code to generate the local time, or perhaps Windows is returning an invalid result from the javascript call? The contents of the cookie is 240, which is correct as a GMT offset (given the DST shift). I think that what's happening on your end is that your server script is adding an hour to what I send back when it shouldn't since it's already corrected for the DST offset - so you're adding in an extra hour.

Does this make sense?

The trouble is, you don't know if the local settings have accounted for DST. You probably should assume they have, and if someone's machine doesn't set it then it's their own darn fault, I guess.

Anyway, if you're using this for the entire site, then this process is fundamentally broken.

It looks like someone reported this fact 4 years ago :)

Mark Richards
GeorgeMatsuo on Mar 9, 2001 at 6:24:23 AMRating: 5

This code helps me keep track of posts to our site.
In your code, the server side script has this line to get the cookies value.

' Get the user's offset value
iUserOffset=cInt(t)

Doesn't this actually get it?
iUserOffset=request.cookies("tz")

And if not, should that be cInt(iUserOffset)?

Sorry for the elementary questions. I'm still learning.

tkroos on Jul 10, 2000 at 12:49:49 PMRating: 3
I thought this article was interesting.  I have searched the Internet and have not found a solution to a problem that I am faced dealing with Daylight savings times.  The GetTimeZoneOffset method does not deal with DST in countries around the world.  Mainly because there are so many countries the changes their start and end dates for their DSTs every 6 months that it is hard to keep track of the correct times.  If anyone knows anything more about how to correctly store timezones as UTC and then retrieve them into the correct times adjusting for DST then I would like to hear from you.  Thanks
stanscott on Apr 25, 2000 at 12:37:05 PMRating: 1

I just pressed the "Reload" button, and the time given is one hour off.  Here in New York, the time is 3:34 PM, but the time shown after the reload is 4:34 PM.  ???

Stan

More Ratings/ Comments


To rate and comment on a resource, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password

Copyright © 1997-2008 InsideDHTML.com, LLC. All rights reserved.