Use Client's Time Zone


This plugin retrieves the time zone of the client using “Automatic Timezone Detection Using JavaScript” ( the first time that a client accesses the site, sets a cookie containing the client’s time zone on the client, and reloads the page. This cookie is then read by PHP and the date_default_timezone_set() function (requires PHP 5 >= 5.1.0) is used to set the default time zone for PHP scripts. Since it runs just after all of the plugins are loaded, it changes the time zone for all of the PHP that follows. It is useful in cases where one wants users to see certain posts on certain days. E.g., if the post slug contains the day number, like “xyz-daynr,” then the post can be specified by “$slug = ‘xyz’.date(j);” in a theme template. The cookie does not expire for ten years, but is reset if the user changes time zones. So, unless the user deletes cookies or moves the page reload only occurs once every ten years.


A remark was posted in our forum stating that sites may experience problems if changing timezones using date_default_timezone_set. WP expects it to always be UTC and display of things in different timezones are achieved in other ways:

The author has not observed any problems on the sites on which this plugin has been tested. Based on the foregoing post, however,it would be wise to check that no date-related operations are going awry after activating this plugin — even though no problems have been observed with the sites tested.

Copyright 2012-2023 M.D. Green, SaeSolved:: LLC


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


  • Settings page.


  1. Extract the use-clients-timezone folder and place in the wp-content/plugins folder.

  2. Enable the plugin.

  3. Set the fallback time zone under Settings->Use Client’s Timezone. (The time zone to use if the script fails to get the client’s time zone.)


Where can I see a working example of this plugin? — the number of days until Ramadan (or day in Ramadan).

You can test this by changing the time on your computer to be in a time zone which is in a different day. E.g., if you live in New York, change the time zone on your computer to that of Sydney. You should see the number of days change. (Check a site like to be sure to get a time zone which is in a different day than the one normally set on your computer.)


This is the ONLY plugin in WordPress’ repository capable of detecting and displaying a site visitor’s local time and time zone on the site’s frontend. Bonus: This plugin is compatible with WordPress 6.3.2 and PHP 8.3.0 (latest versions as of today). Note: If you’re having any issues using this plugin, please visit the plugin’s support forum for a solution. Kudos to the developer!


“Use Client's Time Zone” 是一個開源的軟體。以下的人對這個外掛作出了貢獻。


將 Use Client's Time Zone 外掛本地化為台灣繁體中文版。


任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄



Code added to avoid activating actual use of plugin, other than the settings in the admin screen, during site administration.


Added advice to check that no dated-related operations were adversely impacted by this plugin.


Changed cookie path to be site-wide.


Changed JavaScript so that the page is not reloaded if cookies are not enabled on the client.


Method for obtaining client time zone changed from attempting to retrieve time zone of IP to setting a cookie containing the clients time zone, then reading that cookie.


Original release.