TimeZone Corrector is a JavaScript tool which corrects time and dates in website content.
Most of the websites in Internet are international and often these websites publish dates which are corresponding to their local timezone. Most of the times it’s really hard for visitors from different timezones to catch up with the time difference and here comes the TimeZone Corrector.
With this tool the visitors will be able to see the correct time and date in their timezone only by hovering over the time and date.
Supported formats:
(H|G):i
(h|g):i (a|A)
(H|G):i (m|n).(d|j).Y
(h|g):i(a|A) (d|j).(m|n).Y
(d|j).(m|n).Y (H|G):i:s
(m|n).(d|j).Y (h|g):i:s (a|A)
Examples of these formats:
14:23
7:32 pm
17:29 3.25.2013
4:53am 25.03.2011
15.11.2013 19:23:44
07.29.1990 01:55:23 am
* the date and time formats are according to PHP date() function
What it has?
The script is not dependant of any framework (jQuery/Prototype/etc).
It can be used unlimited times on a page. It is organized as JavaScript Class.
It has two neutral themes and unlimited number of themes can be build with CSS.
It is signular file. The CSS is appended to the head of the document on run time.
It is only 5KB minified and 9KB not minified.
It is cross-browser compatible. It works on IE6+, Firefox, Chrome, Safari, Opera.
How to use it?
First you have to include the script in the document:
<script type="text/javascript" src="tzc/tzc.min.js"></script>
Then you should initialize the class by using this script:
var myTZC = new TimeZoneCorrector('tzcselector');
The first parameter is ID of a HTML element.
The second parameter is (optional) object with options for TimeZone Corrector. Please check all the available options from the table below.
Note: TimeZoneCorrector() class is the same as TZC so use the one you prefer.
Options
Example of using all options:
Timezone settings
How to change the default timezone of your website?
Often your website is hosted in different timezone than yours. In order to correct this you should open file tzc.php in the tzc folder.
In this file you have the following settings:
In order to change the default timezone of your website you should first find the correct timezone name at http://www.php.net/manual/en/timezones.php
Then change the value of the variable $timezone to your selected one.
The other two settings are related to the cookie which the script creates. If you want to change the name of the cookie you can do it by changing the value of the $cookieName variable. If you change the name of the cookie you should set the new name with cookieName option when initializing the TZC script.
Also the cookie expiration time can be changed by $cookieExpiration variable. The value for this variable is in hours.