Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda