Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  24] [ 1]  / answers: 1 / hits: 23932  / 6 Years ago, thu, july 19, 2018, 12:00:00

Firebase Firestore recently changed how they manage timestamps, and I'm unable to retrieve a date object from the timestamp.



How do I get a date object from the new firebase.firestore.FieldValue.serverTimestamp()?


More From » firebase

 Answers
4

You just need to do this:



yourFirestoreTimestamp.toDate()


If you look at the Timestamp object in the console you'll see that .toDate() is a function available by default on each Timestamp.



--



However, please note that when you haven't synced with Firestore yet
FieldValue.serverTimestamp() gives nothing of value.



Only after you have synced with Firestore and the data is fetched again, the prop will be changed from serverTimestamp → to Timestamp



You'll also see much more information saved in a Timestamp object:



preview


[#53939] Monday, July 16, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harrisonnelsonb

Total Points: 63
Total Questions: 112
Total Answers: 97

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;