如何在 Dart 中打印 UTC 时间、欧洲时区和美国时区
How to print UTC time, Europe Time Zone & American Timezone in Dart
我正在尝试在 Dart 中打印时间戳,我想在以下时区打印当前时间:
- 欧洲
- 美国人
- UTC
创建方法:
DateTime timeIn([Duration duration = Duration.zero]) {
return DateTime.now().toUtc().add(duration);
}
用法:
timeIn(); // UTC or GMT
timeIn(Duration(hours: 5, minutes: 30)); // +5.30 (IST)
timeIn(Duration(hours: 2)); // +2.00 (CEST)
timeIn(Duration(hours: -4)); // -4.00 (EDT)
timeIn(Duration(hours: -5)); // -5.00 (EST)
timeIn(Duration(hours: -7)); // -7.00 (MST)
timeIn(Duration(hours: -8)); // -8.00 (PST)
我正在尝试在 Dart 中打印时间戳,我想在以下时区打印当前时间:
- 欧洲
- 美国人
- UTC
创建方法:
DateTime timeIn([Duration duration = Duration.zero]) {
return DateTime.now().toUtc().add(duration);
}
用法:
timeIn(); // UTC or GMT
timeIn(Duration(hours: 5, minutes: 30)); // +5.30 (IST)
timeIn(Duration(hours: 2)); // +2.00 (CEST)
timeIn(Duration(hours: -4)); // -4.00 (EDT)
timeIn(Duration(hours: -5)); // -5.00 (EST)
timeIn(Duration(hours: -7)); // -7.00 (MST)
timeIn(Duration(hours: -8)); // -8.00 (PST)