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

133
Views
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 answers
Answer question

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 Report

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 Report

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