javascriptfirebasereact-nativegoogle-cloud-firestoreredux-firestore

Firebase firestore timestamp to Formatted Date


I am working on a firebase project and for displaying time regarding and entity, what i got is the timestamp. I am working on a react native project. How to convert the received timestamp to properly formatted date. This is the timestamp:

enter image description here

I have this time available in this.props.time , and so i tried this.props.time.toDate() but what i got was an error. Invariant Violation:Objects are not valid as a React child(found: Tue Nov 26 2019 11:51:58 GMT+05:30(Indian Standard Time))


Solution

  • You can create a Date object with new Date(time.seconds * 1000 + time.nanoseconds/1000000) then manipulate it the way you want.