Skip to content
pubscout

timezone

0.11.2, released 6 weeks ago by tools.dart.dev

Time zone databases and time zone aware DateTime class in Dart.

WASM-ready
$ flutter pub add timezone
Source repository

What it does

Provides the IANA time zone database and a TZDateTime class that implements DateTime with support for different locations and time zones. Offers multiple database variants (default, all, 10y) and specific initialization options for Dart libraries, browsers, and standalone environments.

AI-written summary of version 0.11.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to handle dates and times across multiple specific world time zones.
  • Your application requires accurate historical or future Daylight Saving Time (DST) rules.

Skip it when

  • You only need basic UTC or local device time without specific time zone database lookups.
  • You need to automatically detect the current time zone of the device natively without platform-dependent configuration.

Strengths

  • Includes comprehensive IANA time zone database variants (default, all, 10y).
  • TZDateTime implements the core DateTime interface for seamless drop-in usage.

Weaknesses

  • Getting the current timezone of the device is platform-dependent and not a goal of the package.
  • Standalone environment initialization likely will not work in a Flutter environment.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
2

Requires initializing a time zone database variant before use via the appropriate library import (e.g., package:timezone/data/latest.dart).

import 'package:timezone/data/latest.dart' as tz;
import 'package:timezone/timezone.dart' as tz;

void main() {
  tz.initializeTimeZones();
  var detroit = tz.getLocation('America/Detroit');
  var now = tz.TZDateTime.now(detroit);
}

Alternatives

Packages that do the same job and could replace timezone.

  • tempo

    A time and date solution replacing core DateTime with advanced arithmetic and time zone support.

  • get_time_ago

    Relative time formatting for Dart and Flutter supporting 22 locales and CLDR plurals.

  • ntp_dart

    Cross-platform NTP and SNTP time synchronization client for Dart and Flutter.

  • sugar

    Standard library extension for date-times, timezones, collections, and monads.

Works with

Packages commonly used together with timezone: ones it builds on, ones built on it, and its own family.