在DART中获取特定时区的小时

发布于 2025-02-13 23:18:54 字数 268 浏览 0 评论 0原文

我必须在一个飞行中的飞行时间(HH:mm)中展示,该国当地时代的飞机正在起飞或着陆。并且不是根据移动设备的时区,

因此,如何获得时区的特定时间格式(HH:mm),知道我得到了2种不同的TZ格式(根据源)。 欧洲/伦敦,或者可以是+04:00

我可能看到了2个库timezonetime_machine time_machine 但是不知道它是否很好,

非常感谢

I have to display in a Flutter app, the time (HH:MM) of a flight in the local time of the country where the flight is taking off or landing. And NOT according to the timezone of the mobile device

So, how can I get the specific time format (HH:MM) of a Timezone, knowing that I got 2 different TZ format (according to source). Either such as Europe/London or could be +04:00

I have seen possibly 2 libraries timezone or time_machine but don't know if it is good fit

Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

双手揣兜 2025-02-20 23:18:55

不幸的是,datetime DART类仅支持UTC和本地时区。我建议使用以下第三方软件包:

https://pub.dev/packages/packages/timezone 时区:

import 'package:timezone/standalone.dart' as tz;

Future<void> setup() async {
  await tz.initializeTimeZone();
  var detroit = tz.getLocation('America/Detroit');
  var now = tz.TZDateTime.now(detroit);
}

Unfortunately, the DateTime class of Dart only supports UTC and the local timezone. I suggest using the following third party package:

https://pub.dev/packages/timezone

It supports time zones:

import 'package:timezone/standalone.dart' as tz;

Future<void> setup() async {
  await tz.initializeTimeZone();
  var detroit = tz.getLocation('America/Detroit');
  var now = tz.TZDateTime.now(detroit);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文