I'm making a calendar with react, redux, react big calendar and firebase. the problem is that the events are not displayed in the calendar. I think that this is because the format of the dates, is in seconds and nanoseconds.
Searching how to solve this i found that using toDate()
and new Date()
can convert the dates to javascript dates, but it didn't work.
and already read: How do I convert a Firestore date/Timestamp to a JS Date()?
but still cant figure out how to do it
i tried doing this buti get "invalid date":
events.map(event => console.log(toDate(event.start)))
i hope that someone can help me. thanks!!
github: https://github.com/guidomora/peluqueria-new-calendar.git
Code to return the events from firebase:
const startLoadingEvents = async () => {
const querySnapshot = await getDocs(collection(db, "tobias"));
const events = [];
querySnapshot.forEach((doc) => {
events.push({id: doc.id, ...doc.data()});
});
dispatch(setEvent(events))
};
Console:
Event in firebase: