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

98
Views
Invalid Date from an object

I'm fetching a document from firestore and I could already show it in the console too. This is what the data shows:

displayName: "Person1"
items:
  itemAcquired: t {seconds: 1631084326, nanoseconds: 617000000}
  itemName: "Book1"

[[Prototype]]: Object

I tried displaying the itemAcquired in the screen but it display an "Invalid Date":

 <ListItem>
     <Typography>Item Acquired At : </Typography>
          <ListItemText
               primary={new Date(user.items?.itemAcquired).toLocaleDateString()}
             />
           </ListItem>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

JavaScript Date doesn't know about firestore timeStamp object, you can use toDate() function along with toDateString()

const date = itemAcquired.toDate().toDateString()

Also you can try

new Date(temAcquired.seconds * 1000).toUTCString()
about 4 years ago · Juan Pablo Isaza Report
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!