I am saving my timeStamp
to Firestore as DateTime.now()
.
Now, I need to retrieve from this timeStamp a specific day of the week.
For example to reset some variables every Monday
morning.
Please help how it should be done. Many thanks in advance!
Firestore’s timestamp contains a method called toDate()
method that will return a dart DateTime
object.
toDate()
:
timestamp.toDate(); // e.g 2022-01-10 00:00:00.000
From the return of the method, you can now use regular Dart solutions. You can use DateFormat
library to display it as day of the week.
DateFormat
:
DateFormat('EEEE').format(date); // e.g Monday