easy_timezone 1.0.0 copy "easy_timezone: ^1.0.0" to clipboard
easy_timezone: ^1.0.0 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();
  print(jsonEncode({
    '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(),
      '4 times .toTimeZone':
          now.toTimeZone().toTimeZone().toTimeZone().toTimeZone().toString(),
      'EZTimeZoneName': now.toTimeZone().ezTimeZoneName,
      'EZTimeZoneOffset': now.toTimeZone().ezTimeZoneOffset.toString(),
      'format': DateFormat('yyyy-MM-dd HH:mm:ss').format(now.toTimeZone()),
    },
  }));
}
2
likes
0
pub points
64%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on easy_timezone