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

249
Views
Date { NaN } React Native

I'm using react native and I'm trying to convert my timestamp data to date but the output said "Date { NaN }"

       const [eventData1, setEventData1] = useState({});
        
          useEffect(() => {
            database()
              .ref('path')
              .on('value', snapshot => {
                if (snapshot.val() !== null) {
                  setEventData1({...snapshot.val()});
                } else {
                  setEventData1({});
                }
              });
        
            return () => {
              setEventData1([]);
            };
          }, []);
    
     const dates = Object.keys(eventData1).map(
        id => eventData1[id].start_DATE * 1000,
      );
      const sDate = new Date(dates);

Outputs

    console.log(dates) -----> //[1648703685000, 1648623600000]//
    
    console.log(sDate) ------> //Date { NaN }//
    
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

dates is an array of UNIX timestamps [1648703685000, 1648623600000] which you are trying to pass to the Date() constructor. But Date() does not take an array but can take a single timestamp as a parameter. You will have to loop over the dates to get the start and (presumably) end date parsed.

const dates = [1648703685000, 1648623600000]
const parsedDates = dates.map(date => new Date(date));
const [startD, endD] = parsedDates;

console.log("Start:", startD);
console.log("End:", endD);

BTW: You can do the above in one line if you want to:

const [startD, endD] = dates.map(date => new Date(date));
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!