I can't seem to find anywhere in the Web/Javascript docs anything about saving Dates to the Firestore. In Swift, I create a variable using NSDate and then Firebase is able to store that as a date object in the database. Is there similar functionality in Node.js? Can I use the date-and-time package or is there native support for Dates in Node.js?
From the Firestore documentation on saving data of supported types:
var docData = { stringExample: "Hello world!", booleanExample: true, numberExample: 3.14159265, dateExample: admin.firestore.Timestamp.fromDate(new Date("December 10, 1815")), arrayExample: [5, true, "hello"], nullExample: null, objectExample: { a: 5, b: { nested: "foo" } } }; db.collection("data").doc("one").set(docData).then(function() { console.log("Document successfully written!"); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With