Reputation: 47
I save dates in a format like
in Cloud Firestore
How do I get it in Date format in Node.js?
Upvotes: 2
Views: 2592
Reputation: 1962
When you get timestamps from Firestore they are of the following type:
To convert this into a Node.js timestamp you can use the .toDate() function.
For example, for a document like the following:
We can use something like:
db.collection('[COLLECTION]').doc('[DOCUMENT]').get().then(function(doc) {
console.log(doc.data().[FIELD].toDate());
});
and the output will be like:
2019-12-16T16:27:33.031Z
Upvotes: 4