Kodali444
Kodali444

Reputation: 1443

how to store date in the firebase with type 'timestamp' instead of 'map' from reactjs

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())

enter image description here

Upvotes: 2

Views: 1354

Answers (1)

zenwraight
zenwraight

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

Related Questions