I have a list of string dates that I retrieve from a website.
const appDate = await page.evaluate(() => {
const dates = Array.from(document.querySelectorAll('li.det-comment-list-every div.comment-date'))
return dates.map(font => font.textContent)
});
I tried to convert them into Date objects in a for loop.
Example of appDate array :
['2018/8/22 13:52', '2018/5/11 22:36', '2018/7/20 07:13', '2018/5/30 04:04', '2018/3/26 18:21', '2019/3/20 17:46', '2019/3/18 13:01', '2019/3/18 07:27', '2019/3/17 23:10', '2019/3/17 20:39' ]
let nDates = [];
for(let date of appDate){
var d = new Date(date);
nDates.push(d);
}
console.log(nDates);
However, the console gives me "invalid date".
[ Invalid Date, Invalid Date, Invalid Date, Invalid Date, Invalid Date, Invalid Date, Invalid Date, Invalid Date, Invalid Date, Invalid Date ]
How can I get my dates to convert into date format?