0
0

FlutterでDatetime型の時間がずれる

Posted at

現象

final datetime = Datetime.now();
print(datetime); // ここが9時間前になってしまう
print(datetime.timeZoneName); //  GMT <- JSTにしたい

環境

  • Android Studio (Jellyfish)
  • Android StudioのEmulator(Pixcel7)
Flutter 3.33
Dart 3.5.0

原因

  • DateTimeクラスは端末のタイムゾーンに依存している

対応策

エミュレーター上のSetting(設定)からSystem(システム)で日付と時刻のタイムゾーンを設定する

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0