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

202
Views
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
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!