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

532
Vistas
How to convert Firestore Timestamp to Date() - Firestore V9

Before updating to V9, I use this:

let data = doc.data();

for (let field in data) {
    let value = data[field];

    // If value is an instance of Timestamp, convert it to javascript Date()
    if (value instanceof firebase.firestore.Timestamp) {
        data[field] = value.toDate();
    }
}

But now, after updating to V9, I run into 2 problems, and the documentation mentions nothing about Timestamp for javascript SDK:

  1. firebase.firestore.Timestamp is no longer available to use to check if a field is a Timestamp Object.
  2. None of the field has the "toDate()" function any more.

So my questions are, with the javascript V9 SDK:

  1. How do I check if a field is an instance of Timestamp?
  2. How do I convert an instance of Timestamp into Date() object?
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

How do I check if a field is an instance of Timestamp?

You can import Timestamp class from Firestore package.

How do I convert an instance of Timestamp into Date() object?

This method exists on a Timestamp object.

import { Timestamp } from "firebase/firestore"

const timeObj = new Timestamp();

console.log(timeObj instanceof Timestamp)
console.log(timeObj.toDate());
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