Flutter - When you pull Instant Clock with DateTime, different time comes from normal

Viewed 108

I have an app and I will just add hour to it. I wrote a code like this:

timePush() {
  var now = DateTime.now().toLocal();
  var hour = now.hour;
  var minute = now.minute;
  var print = hour.toString();
  return print;
}

The time in my country is now 03. But the output I got from the code is 00. So 3 hours back. How can I solve this problem? Thanks in advance for the help.

1 Answers

Are you running on an emulator? If you are make sure to adjust the time inside the emulator settings accordingly.

Set the time settings like you would on your android/ios device.

Related