worldtime 1.4.1 copy "worldtime: ^1.4.1" to clipboard
worldtime: ^1.4.1 copied to clipboard

World Time Plugin uses a free public API to access local time info for a specific geolocation or TZ time zone.

1.2.0 #

A Flutter package to get the time of a specific time zone or geo location.
It also includes an easy to use formatter for DateTime with customizable formatting. Comes with built-in extensions for time frame comparison.

Features #

  1. Get current time from EZ Time Zone
  2. Get current time from Latitude and Longitude
  3. Format a Flutter DateTime object to a pretty String formatted text to your liking
  4. Check if a date compared to another is in the same timezone, year, month, week, day, hour or minute

Example App

Short example code #

import 'package:worldtime/worldtime.dart';

final _worldtimePlugin = Worldtime();

final String myFormatter = 'time - \\h:\\m, date - \\D/\\M/\\Y';

final DateTime timeAmsterdamTZ = await _worldtimePlugin
    .timeByCity('Europe/Amsterdam');

final DateTime timeAmsterdamGeo = await _worldtimePlugin
    .timeByLocation(latitude: 52.3676, longitude: 4.9041);

final String resultTZ = _worldtimePlugin
    .format(dateTime: timeAmsterdamTZ, formatter: myFormatter);

final String resultGeo = _worldtimePlugin
    .format(dateTime: timeAmsterdamGeo, formatter: myFormatter);

Walk through #

Import the plugin

import 'package:worldtime/worldtime.dart';

Initiate the plugin

final _worldtimePlugin = Worldtime();

Create a formatter.

final String myFormatter = 'time - \\h:\\m, date - \\D/\\M/\\Y';

Example with TZ Time Zone #

Get the time in Amsterdam.

final DateTime timeAmsterdamTZ = await _worldtimePlugin
    .timeByCity('Europe/Amsterdam');

Get and store the value:

final String resultTZ = _worldtimePlugin
    .format(dateTime: timeAmsterdamTZ,formatter:myFormatter);

Example with Coordinates #

Amsterdam's coordinates are: 52.3676° N, 4.9041° E => latitude: 52.3676, longitude: 4.9041
Get the time in Amsterdam's coordinates.

final DateTime timeAmsterdamGeo = await _worldtimePlugin.
    timeByLocation(
        latitude: 52.3676,
        longitude: 4.9041,
    );

We will use the same formatter. ('time - \h:\m, date - \D/\M/\Y')

Get and store the value:

final String resultGeo = _worldtimePlugin.
    format(
        dateTime: timeAmsterdamGeo,
        formatter:myFormatter,
    );
9
likes
150
points
223
downloads

Publisher

unverified uploader

Weekly Downloads

World Time Plugin uses a free public API to access local time info for a specific geolocation or TZ time zone.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, http, intl, plugin_platform_interface

More

Packages that depend on worldtime