Easy Time Zone Offset Calculator
Do you have your office hours posted on your contact page?
If you're in business, you must have received emails asking what time zone you're in to determine a good time to make a telephone call.
Have you ever received a telephone call at 4:00 in the morning from a time zone 15 1/2 hours away? ("Oops, I thought it would be 4:00 in the afternoon!")
Make it easy for your customers. Post your office hours in *their* time zone as well as your own.
Do you have regularly scheduled chats or other internet events? Do you have a "click here to see what time that would be in your time zone" link?
Make it easy for your people. Yes, post the schedule in both your time zone and theirs.
Not only is it easy for your customers and site visitors. It's also easy for you!
The Easy Time Zone Offset Calculator is created with JavaScript. It's easy to install.
Install it once and forget about it. Easy Time Zone Offset Calculator even calculates Daylight Savings time for you.
Want to impress the newbies? You can even present the current clock time in both your and your visitor's time zone.
Go to the example page and see if you would want something like this.
If "yes," read on.
(Note: If your geographical area is in Central Daylight Savings or Eastern Standard Time, US, then your time zone is the same as the time zone in the example.)
Instructions for specifying the various variables in the JavaScript code are in the code itself. They're all pretty easy, except the first one.
That first one is the number of minutes you are away from Greenwich Mean Time, also called UT for Universal Time. The number could be positive or negative, depending on whether you are east or west of the zero line.
But you don't have to do any "number of minutes" calculation. All you have to do is go to /library/demo/eztzoffset.php and it is automatically calculated for you.
Yep, it's easy for you as well as your customers :)
The rest os fairly simple.
You specify when your daylight savings period starts and ends (if you have one), and you set some default times. You specify whether you want a 12- or 24-hour clock and whether or not you want the day of the week printed.
The large block of JavaScript code that is between the <head> and </head> tags, put it between the <head> and </head> tags on your page.
The rest is the fun part.
If you want to print a pre-determined time in the visitor's time zone, such as the schedule of an event coming up, you use the function get_future().
If you want to print the time "in real time", you use get_current('here') for your current time and get_current('visitor') for the visitor's current time.
See the Example Page at /library/demo/eztimezone.php for examples of use.
When you use get_future(), it will calculate the visitor's clock time according to either the defaults you specified when you installed the code or, if they have been changed, according to the last time those defaults were changed.
If you want to change the defaults, change them right before you use get_future(). You can change the appointment hour, minute, whether it's AM or PM, and what weekday it falls on. The Example Page shows how to do it.
get_future() will print the day of the week if a day of the week is specified for the appointment. Otherwise, it won't.
get_current() will print the day of the week if the default say so. Otherwise it won't. You can change the default right before you use get_current(). The Example Page shows how to do it.
When you get it done, your site visitors will "ooh" and "aah" about your conquest of the time zones.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©2000 Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.