easy_timezone 1.0.0 easy_timezone: ^1.0.0 copied to clipboard
A very easy to use timezone package to Dart and Flutter.
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()),
},
}));
}