Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
React Native map function to get date drom database

I would like to display the date form my database (firestore) on my frontend but it only gives me seconds and nanoseconds as values when it clearly correct in the database.

I am doing a map function to get the data from the database.

<Text style={styles.datecon}>{comp.date.seconds}</Text>

The above code works but gives me a string of all the seconds.

<Text style={styles.datecon}>{comp.date}</Text>

The above code doesn't work due to it being an object and needs to be expanded but I can onlyu expand it to seconds and nanoseconds.

Console.log

Here is where I console.log the data

Firestore

Here is the data in firestore

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Create a function to convert seconds to date.

const convertToDate = (seconds) => {
    return new Date(seconds).toString();
}

Then use it in your jsx.

<Text style={styles.datecon}>{convertToDate(comp.date.seconds)}</Text>
about 4 years ago · Juan Pablo Isaza Denunciar

0

Thanks to the answer (from bgcodes) I mahnage to fix the error and also fixing the date to not say 1970 you should just *1000 to get the correct date

const convertToDate = (seconds) => {
    return new Date(seconds*1000).toString();
}
<Text style={styles.datecon}>{convertToDate(comp.date.seconds)}</Text>
about 4 years ago · Juan Pablo Isaza Denunciar

0

What you get from the SDK is a Firestore-specific type called a Timestamp, which has helpful methods listed here.

One of these is to get a Date object from the timestamp, which you'd do with , much simpler with:

<Text style={styles.datecon}>{comp.date.toDate()}</Text>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda