1

我目前正在尝试为我的应用程序做一个倒计时,但我想使用 utc+1。

问题是我不知道我在“UTC+1”中使用它的方式是否正确。

final hours = new DateTime.now().toUtc().hour;
final minutes = new DateTime.now().toUtc().minute;
final seconds = new DateTime.now().toUtc().second;

我目前正在使用这个。

final hours = new DateTime.now().add(Duration(hours: 1)).toUtc().hour;
final minutes = new DateTime.now().toUtc().minute;
final seconds = new DateTime.now().toUtc().second;

谢谢你。

4

1 回答 1

0
void main() {
  final now = DateTime.now().toUtc();
  print(now);

  final later = now.add(Duration(hours: 1));
  print(later);
}

应该管用。

于 2020-09-27T06:01:49.637 回答