I am using flutter to build an app, so therefore I am also using dart. I need to use the DateTime class for a calendar.
When I execute the following line of code:
print(DateTime.now())
It prints:
2022-12-29 15:27:11.147472
I executed this code on 2023-01-04 and I executed the code at about 3:03 pm.
How do I fix this?
Thanks!
2
Answers
The issue was that the simulator that I was running the program on had the wrong date so it made the app show the wrong date as well.
Thank you to Soliev for helping me with the issue!
There might be a problem with the device’s system clock. Make sure that the device’s system clock is set to the correct date and time.
There might be a problem with the device’s time zone settings. Make sure that the device’s time zone settings are correct.
There might be a problem with the app’s code. Double-check the code to make sure that there are no errors or bugs that could be causing the incorrect date and time to be returned