0

DateTime.now() returns the wrong time i.e, exactly with a delay of 7:30 hrs. But the same app returns the correct time in Hauwei Nova 3i.

Steps to Reproduce

  • create a app

  • print DateTime.now() in initstate or wherever you want

  • run the app in Xioami Mi 4i Android Version(5.02 LRX22G) connected in a Wi-Fi

Output

Launching lib/main.dart on Mi 4i in debug mode...

Initializing gradle...

Resolving dependencies...

Running Gradle task 'assembleDebug'...

Built build/app/outputs/apk/debug/app-debug.apk.

Installing build/app/outputs/apk/app.apk...

Syncing files to device Mi 4i...

I/flutter (16029): 2019-06-15 05:54:32.248432

Flutter Doctor

[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Linux, locale en_IN) • Flutter version 1.5.4-hotfix.2 at /home/androiddeveloper/flutter • Framework revision 7a4c33425d (7 weeks ago), 2019-04-29 11:05:24 -0700 • Engine revision 52c7a1e849 • Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at /home/androiddeveloper/Android/Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-28, build-tools 28.0.3 • Java binary at: /snap/android-studio/76/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Android Studio (version 3.4) • Android Studio at /snap/android-studio/76/android-studio • Flutter plugin version 36.1.1 • Dart plugin version 183.6270 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)

[✓] IntelliJ IDEA Community Edition (version 2019.1) • IntelliJ at /snap/intellij-idea-community/152 • Flutter plugin version 35.3.3 • Dart plugin version 191.7479.14

[✓] Connected device (1 available) • Mi 4i • 97103c6a • android-arm64 • Android 5.0.2 (API 21)

! Doctor found issues in 1 category.

7
  • That returns the time in the local timezone. Check the device timezone in settings. Jun 15, 2019 at 12:45
  • @RichardHeap I have checked all the Date and Time Settings. The Settings are prefect. But the DateTime.now() method returns a wrong time... Jun 17, 2019 at 4:45
  • Try printing the timezone that the phone reports. Jun 17, 2019 at 11:53
  • @RichardHeap I have Printed DateTime.now().timeZoneName and it returns _TZif Jun 17, 2019 at 13:06
  • I have used a package flutter_native_timezone and I got the current Time Zone as Asia/Calcutta, But the DateTime.now() stills returns a wrong time. Jun 17, 2019 at 13:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.