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

204
Vistas
How do you query a timestamp field in Firebase?

Question

How do you execute a query that filters based on a timestamp field in firebase?

Equivalently, what must I fill the ... in:

const q = query(ref, where("time", "<", ...));

so as to filter by a the current date (for example)?

  • Timestamp.now() (Timestamp object)?
  • new Date() (Date object)?
  • Date.now() (Time in milliseconds)?
  • Math.round(Date.now()/1000) (Time in seconds)?

More Context

I am trying to make a collection query based on the timestamp field of the documents. i.e.

where("next_spaced_revise", "<", ...)

I am using react-hooks-firebase, so make this query via:

const [values, loading, error] = useCollectionData(q);

I am getting a very erroneous behaviour that I am struggling to debug. What happens is that the react component (which the above hook is in) keeps on getting mounted and unmounted. When I place a console.log within preamble code of the JSX component, it gets called over and over.

This behaviour also happens when I don't use react-hooks-firebase and instead use the promises of vanilla firebase getDocs

I have found one error message, which seems to reflect the mentioned behaviour of mounting and unmounting:

Error message Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render

After more investigation, I believe this behaviour occurs whenever an incorrectly constructed query is made. Hence, why I believe that this boils down to getting the correct term to fill ... in where("next_spaced_revise", "<", ...)

Image of Example doc Please note that what I called "time" in my example corresponds to "next_spaced_revise"

about 4 years ago · Juan Pablo Isaza
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