gmt 0.7.3 copy "gmt: ^0.7.3" to clipboard
gmt: ^0.7.3 copied to clipboard

Get current datetime in GMT from internet (example.com, google.com or your own urls) and return DateTime in UTC.

GMT #

Get current datetime in GMT from internet (example.com, google.com or your own urls) and return DateTime in UTC.

This package provides an easy way to get the current DateTime in UTC from the internet. It will get DateTime from the headers of https://example.com, https://google.com or your own URLs. On web platform, the package will use headers from current URL to avoid CORS error.

Usage:

var now = await GMT.now();

You can create your own list of URLs and timout of each URL:

var now = GMT.now(
    urls: ['https://www.example.com', 'https://www.google.com'],
    timeoutOfEach: const Duration(seconds: 1),
    );

If you want to get local DateTime if it gives error or timeout then using (default is return null):

var now = await GMT.now(returnLocalIfError: true); // Default is false

You can also set a timeout for this whole function by using:

var now = await GMT.now(timeout: const Duration(seconds: 5));
1
likes
140
pub points
70%
popularity

Publisher

verified publisherlamnhan.dev

Get current datetime in GMT from internet (example.com, google.com or your own urls) and return DateTime in UTC.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

http, universal_io

More

Packages that depend on gmt