Overview

Timezone Detect is a lightweight module that leverages the jsTimezoneDetect library (included with the module) for automatic detection and setting of a user's timezone via javascript. It can set a user's timezone automatically upon first login, and update it on every login if desired.

Benefits

The setting of user timezones is often fraught with confusion and frustration.

To start with, some users will never update their timezone settings manually, even when prompted to do so at every login; I know this from experience running a large website where timezone settings are an important factor. These same users will sometimes complain about confusions caused by incorrect timezone settings, though they have not bothered to update their accounts.

The users who do follow through on updating their timezone settings are often confused about which timezone they inhabit, and which timezone they should select--even when provided with a map to click on. The IANA timezone codes (e.g. "America/Chicago") are not immediately obvious to everyone, and some users are confused when they do not see their particular city listed as an option.

This module mitigates these kinds of issues by setting a sane "best guess" default timezone for every user at first login, so that you can:

  1. Be confident that dates and times are always displayed correctly for all users.
  2. Carry out time-sensitive cron tasks at the best time for all users (e.g. updating credits overnight, sending out emails in the morning).
  3. Avoid the common confusions that arise when people are asked to set their timezones manually.

Installation and Configuration

Note: The jsTimezoneDetect library which this module uses is included in the module download: there is no need to download or install the library separately.

This module is designed to be "set it and forget it": it does not require any special installation or configuration beyond enabling the module. It defaults to setting a user's timezone automatically at login if their timezone is not yet set.

If desired, there are a couple of options that can be configured by visiting admin/config/regional/timezone_detect.

For general instruction on how to install and update Drupal modules see http://drupal.org/getting-started/install-contrib.

Javascript timezone detection compared to other methods

In creating this module I did a decent bit of research while attempting to find the best possible method for automatic timezone detection for web users; I was open to alternative solutions (such as IP-based and browser-based geolocation methods), and considered a wide variety of libraries, APIs, and web services. In the end I determined that javascript detection was best for my needs despite its limitations, primarily because:

  1. Javascript detection is lightweight and inexpensive.
  2. IP-based geolocation methods break down for users who are behind a proxy, using a VPN, or are in a region that has recently changed timezones (or for users on border areas in low population regions, where geolocation data may be sparse and inconsistent).
  3. Browser-based geolocation, while often very accurate (since it takes multiple factors into account), is not silent: the user must pass a browser alert and click a button to "allow access to your location," which many users are loath to do.

The biggest downfall of the javascript method is that it will often pick an "equivalent timezone" rather than the user's "actual" IANA timezone code (so "America/Chicago" may be chosen for a user instead of "America/Winnipeg", for instance, which are for all intents and purposes, equivalent timezones). For more information about the limitations of javascript timezone detection, see the readme, or visit https://github.com/pellepim/jstimezonedetect.

Project information

Releases