JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript

Displaying Author Local Time

1. Introduction and Sample

Join the Discussion

Questions? Comments?

Have you ever thought how useful it might be to display your local time on your web site so that visitors to your site will know what time it is where you are? If you have a site where you expect to interact with the visitors then you may have.

There are three computers involved in getting the information transferred from you to the visitors to your web site. There is your computer that you work on to create the web pages, there is the server where the pages are stored, and there is the visitor's computer that they use to view the pages.

You can place scripts in your page that run on the visitor's computer and you can run programs from the server. Nothing that you place in your web page can access any information from your computer.

Given this, you might think that arranging to display your local time on the page for your visitor to see it might be impossible. Not so as you can see from the time displayed below. In this instance, my computer is located in Australia, the server is in America and your computer is located wherever in the world that you are.


The script that displays the time actually runs on your computer and relys on your having your timezone and local time set correctly in order to calculate what the time is at my location.

So let's Get the Script and then we can look at what we need to do to customize it for your timezone.

Introduction | Get the Script | Configure the Script | Daylight Saving

Note that the script and the descriptions of the functions that it contains are rewritten from the "Ask Felgall" website with the permission of the copyright owner.

Explore JavaScript

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript
  4. Script Library
  5. Date and Time Scripts
  6. Author Time Script

©2009 About.com, a part of The New York Times Company.

All rights reserved.