Jump to content

Recommended Posts

Posted

As we close out 2025, I'm pleased to share a new module that I've been using in production: FieldtypeTimezone / InputfieldTimezone.

๐ŸŽฏ What It Does

A straightforward timezone fieldtype that handles the complexity of timezones automatically - no configuration needed, just install and use.

Key Features:

  • Dynamic UTC offsets - automatically calculates current offsets with DST support
  • Simple format - displays as "Country โ†’ City (UTC+X)"
  • Intelligent caching - 24-hour cache for optimal performance
  • Production-ready - strict validation at all levels
  • Complete coverage - all major world timezones included

๐Ÿ’ก Why I Built This

Working on global websites (wine shop, news portal), I needed a reliable way to handle user timezones without complexity. The module automatically adjusts UTC offsets for DST:

  • America/New_York: UTC-5 in winter, UTC-4 in summer
  • Europe/London: UTC+0 in winter, UTC+1 in summer

๐Ÿš€ Basic Usage

<?php
// Display date in a nice English format
$timezone = $page->tz; // e.g., "America/New_York"
if ($timezone) {
    $tz = new \DateTimeZone($timezone);
    $datetime = new \DateTime('now', $tz);
    echo $datetime->format('F j, Y \a\t g:i A T');
}
?>

Perfect for:

  • User profiles with timezone preferences
  • Event calendars with automatic time conversion
  • Global applications requiring accurate time display
  • Any site serving users across multiple timezones

๐Ÿ“‹ Requirements

  • ProcessWire 3.0.0+
  • PHP 8.1+

๐Ÿ“ฆ Installation

GitHub: https://github.com/mxmsmnv/FieldtypeTimezone

cd /path/to/processwire/site/modules/
git clone https://github.com/mxmsmnv/FieldtypeTimezone.git

Or download and extract to /site/modules/FieldtypeTimezone/

Then install via Modules โ†’ Site โ†’ FieldtypeTimezone

๐Ÿ“– Documentation

Full documentation with practical examples, API methods, and advanced usage scenarios is available in the GitHub repository.

๐Ÿค Feedback Welcome

The module has been tested in production on several sites, but I'd appreciate any feedback, suggestions, or bug reports from the community.


Happy New Year to the ProcessWire community! ๐ŸŽ‰


  • Like 12
  • Thanks 1
Posted

Thanks for this @maximusย - timezone DST changes are definitely an annoyance in development.

I am curious though why you have a limited set of timezones available, rather than the complete set? I feel like it might be particularly problematic if you rely on a service likeย https://ipapi.co/ย to determine the user's timezone from their IP address. Many of the timezones returned from that are not likely to match your list. I can see that the way you have organized them makes it much simpler for user selection, and maybe that is your primary goal but I still wonder about how it might impact its functionality.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
ร—
ร—
  • Create New...