I have the following problem:
Given this array of dates in string format:
let arrayStringDate = ["10/01/1995", "20/01/1995", "21/01/2010", "25/01/2010"]
I am trying to parse everything in Date
the following way:
let parsedArray = arrayStringDate.map(date => new Date(date));
The result is that it parses only the first item and the others indicate that they are invalid:
[Sun Oct 01 1995 00:00:00 GMT+0100 (hora estándar de Europa central), Invalid Date, Invalid Date, Invalid Date]<br>
I also tried to do it by going through the array item by item but I get the same result. As you can see, it only parses the first string , the others cause an error. What I can be doing wrong?
The dates must be in mm/dd/yyyy format like this:
The default date format in Javascript is
mm/dd/yyyy
, but it can also work with formattingyyyy/mm/dd
and you just need:reverse()
.join('/')