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

Scott Isaacs on Apr 2, 2000 at 11:52:37 AMNo Rating

We haven't written it up.

For pages with a high read-to-write ratio (such as this page), we either cache the generated page in memory or in a SQL table.  When the page is generated we first check the cache - if cached we return the page - if not cached we generate it and store it in the cache.  Whenever there is an update, we have code the cached version forcing them to be regenerated on the next read.

Since each page with time information can be slightly different, we need to add an extra dimension to our cache (the timezone). 

Scott

pemeyer on Apr 2, 2000 at 9:21:00 AMRating: 3
This one is pretty easy to solve... but you mention it not helping your cache system. What cache system and do you have articles that discuss it? This seems to be a big issue with semi-dynamic pages that eat the server resources when they could be cached. We are starting to add more semi-dynamic materials to our site and I am concerned about system resources.
flachance on Mar 28, 2000 at 8:53:12 PMRating: 3

I was faced with a similar problem just last week.  The solution I found was, I think simpler, but may not work with older browser (version 3 and earlier I think).

My code was written in JavaScript.  I simply send the time to the client from ASP using toUTCString().  On the client side, the UTC time is actually in a function call that simply takes the UTC date and initialize a date object with it.  Then the function simply does a document.write(date.toLocaleString()), et voila.  I didn't have to worry about the timezone offset and no cookies required.

Here is the client side code for the function:

<HTML>
<HEAD>
<script language="JavaScript">
function LocalTime(sUTC)
{
   var   dTime = new Date(sUTC);
        
   document.write(dTime.toLocaleString());
}
</script>
</HEAD>
<BODY>

The local time is <script>LocalTime('Tue, 28 Mar 2000 20:11:49 UTC')</script>

</BODY></HTML>

Strype on Mar 28, 2000 at 7:45:15 PMNo Rating
Win2k and IE5.0
Scott Isaacs on Mar 27, 2000 at 7:19:21 AMNo Rating
Forgot to also ask what browser version and platform?  Thanks again.
Strype on Mar 26, 2000 at 2:19:32 PMNo Rating
EST
Scott Isaacs on Mar 26, 2000 at 1:42:54 PMNo Rating
What time zone are you in?  Thanks
Strype on Mar 26, 2000 at 10:41:30 AMRating: 2
It did not work in your example.. the time that appeared when i reloaded the page by clicking the button told me it was 6:40pm when my clock says 1:42pm.

Most Recent 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.