Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
String is not writing as a timestamp to firebase

so I had the date string Friday, April 15, 2022 and I converted it to Thu Apr 14 2022 00:00:00 GMT+0100 (Irish Standard Time) by string manipulation and now I'm writing it to firebase but it is saving as a string?

I am writing it to firebase like this:

const event = {
            Time: eventTime,
            start: newEventString,
            title: eventName,
            allDay: true
            
        }
        allEvents.push(event)

        const db = fire.firestore();
        db.collection("userEventsCal/"+currentUserUID+"/activities").add({event})

Because I am using reactFullCalendar, and the events isn't showing up in the calendar because of the date I think.

I am calling the user event info like below but when I use toDate() on the event start date it can't use it on a string because I know firebase returns a timestamp so I am not sure how to go about fixing this because none of the events are showing up in the react full calendar.

const getUserInfo2 = async () => {
  let currentUserUID = fire.auth().currentUser.uid

      console.log(currentUserUID)
      const qSnap = await fire
       .firestore()
       .collection('userEventsCal')
       .doc(currentUserUID)
       .collection("activities")
       .get()
    
    const data = []
    data = (qSnap.docs.map(d => ({ 
      id: d.id, 
      title: d.data().event.title, 
      start: d.data().event.start.toDate(),
      allDay: d.data().event.allDay,...d.data() })));
    
    
   
    setData([...data])

}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You must save a Date or Firestore Timestamp object to save it as a timestamp in Firestore and not a string with a specific format:

const eventTime = "" // your date string

// TODO: convert the string to a Date

// const fireTimestamp = firebase.firestore.Timestamp.fromDate(new Date());

const eventTimeDate = new Date(eventTime)

// save this eventTimeDate in Firestore document

You might have to format your date string a bit to use Date() constructor and create a Date object. Checkout Parsing a string to a date in JavaScript for additional info.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!