Reputation: 165
I have a flutter app where I am storing activities with an activity date in my firebase.
When showing those activities in my app I noticed that the Date gets converted differently from different devices.
The output in my Virtual Device when debugging is in the end the 29.07.2018 instead of the 30.07.2018. How can I fix this?
Upvotes: 0
Views: 576
Reputation: 317487
Firestore Timestamps are always stored in UTC, like pretty much all other date types in any modern operating system. What you see in the Firebase console is the date formatted for the locale configured on the local machine that's viewing the console.
If you want to format a timestamp in your app, you should look into using the date formatting utilities provided by Flutter or whatever platform you're using. Usually users expect to see timestamp formatted for their own chosen locale.
Upvotes: 0
Reputation: 1275
This may happen because of locale. Try to use DateFormat
from https://pub.dev/packages/intl
Upvotes: 2