i have the next array of dates in miliseconds
const dates = date?.rangeOfDates
console.log(dates)
(4) [1661281243730, 1661454043730, 1661886043730, 1661713243730]
Im trying to turn it into Date format the next way:
const listOfDates = new Date(dates).toLocaleDateString()
It gives me an Invalid Date error in the console but when I try to change it manually in the next way it works good:
console.log(new Date(1661281243730).toLocaleDateString())
--> 8/23/2022
>Solution :
Just use an array map to convert it.
const array = [1661281243730, 1661454043730, 1661886043730, 1661713243730];
array.map(x => new Date(x).toLocaleDateString());