Use Client's Time Zone
Sets the default time zone for PHP scripts to that of the client.
The facts
- Rating
- 4.4★ from 7
- Active installs
- 100+
- Price
- Free
- Last updated
- 13 Oct 2023
- Added
- Sep 2012
- Requires WP
- 1.5
- Tested up to
- WP 6.3.10
- Downloads
- 10,538
Our analysis
AI-assistedUse Client's Time Zone is a WordPress plugin that detects the client's time zone using JavaScript and sets a cookie to store this information. When a user first accesses the site, the plugin reloads the page to apply the detected time zone for all subsequent PHP scripts. This can be useful for displaying posts based on specific days, particularly if the post slug includes the day number.
The plugin is designed for users who need to present content according to the client's local time. It is suitable for websites where time-sensitive content is relevant, such as event scheduling or date-specific posts.
Best for: Websites that need to display content based on the user's local time.
What it does well
- ✓Retrieves and sets the client's time zone automatically
- ✓Uses a cookie that lasts for ten years unless changed
- ✓Can help display time-sensitive content correctly
Where it falls short
- •May cause issues if changing timezones using date_default_timezone_set
- •Not all users may experience problems, but caution is advised
Verdict
This plugin can be beneficial for specific use cases involving time-sensitive content, but users should be cautious about potential issues with date handling in WordPress.
From the developer
drmikegreen's own description of Use Client's Time Zone, lightly tidied.
This plugin retrieves the time zone of the client using “Automatic Timezone Detection Using JavaScript” (http://pellepim.bitbucket.org/jstz/) 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.
NOTE:
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:
https://vip.wordpress.com/documentation/vip-development-tips-tricks/use-current_time-not-date_default_timezone_set/
https://weston.ruter.net/2013/04/02/do-not-change-the-default-timezone-from-utc-in-wordpress/
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
License
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.