easy_timezone 1.0.2+1 copy "easy_timezone: ^1.0.2+1" to clipboard
easy_timezone: ^1.0.2+1 copied to clipboard

A very easy to use timezone package to Dart and Flutter.

example/example.dart

import 'dart:convert';

import 'package:easy_timezone/easy_timezone.dart';
import 'package:intl/intl.dart';

void main() {
  // print(EasyTimeZone.allTimeZoneAndOffset());
  EasyTimeZone.setFromTimeZone('asia/shanghai');
  final now = DateTime.now();
  var encoder = new JsonEncoder.withIndent("     ");
  print(encoder.convert({
    'default': {
      'now': now.toString(),
      'utc': now.toUtc().toString(),
      'TimeZone': now.timeZoneName,
      'TimeZoneOffset': now.timeZoneOffset.toString(),
      'format': DateFormat('yyyy-MM-dd HH:mm:ss').format(now),
    },
    'EZTimeZone': {
      'now': now.toTimeZone().toString(),
      '.utc.toTimeZone': now.toUtc().toTimeZone().toString(),
      'EZTimeZoneName': now.toTimeZone().ezTimeZoneName,
      'EZTimeZoneOffset': now.toTimeZone().ezTimeZoneOffset.toString(),
      'format': DateFormat('yyyy-MM-dd HH:mm:ss').format(now.toTimeZone()),
    },
  }));
}
2
likes
140
pub points
65%
popularity

Publisher

unverified uploader

A very easy to use timezone package to Dart and Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on easy_timezone