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(eventData1) -----> //[1648703685000, 1648623600000]//
console.log(sDate) ------> //Date { NaN }//