Reputation: 1443
From react application i'm getting date from a datepicker. i'm trying to save it on firebase. It's saving properly in the database but not TYPE as 'timestamp', instead it's saving like 'map'. I'm sending data to firebase function created by us. from that function we are saving data to collection. any suggestion please.
const d = new Date("27-5-2021")
firebase.firestore.Timestamp.fromDate(d)
(OR)
firebase.firestore.Timestamp.fromMillis(d.getTime())
Upvotes: 2
Views: 1354
Reputation: 2000
I think you will need to do something like this to save it as timestamp on firebase.
firebase.firestore.Timestamp.fromDate(date).toDate());
Upvotes: 1