When I console log my creation at the terminal it shows
"creation": Object { "nanoseconds": 420000000, "seconds": 1620290402, },
how can i format it into date and time so i can use it on frontend
When I console log my creation at the terminal it shows
"creation": Object { "nanoseconds": 420000000, "seconds": 1620290402, },
how can i format it into date and time so i can use it on frontend
Here's a quick format that I've used in the past for Firebase to JS strings:
//Firebase Timestamp Fix
creation = new Date(creation.seconds * 1000);
const formattedDate = creation.toLocaleDateString("en-US");
const formattedTime = creation.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true });
const newDate = `${formattedDate} ${formattedTime}`;
The javascript doesn't know anything regarding the firebase time stamp.It simply gives you the object
So simply use toDate(). For further refernce check this source toDate() firestore