I have array of datestring that consist of date and time and I would like to split the date time as there is '@' in between and combine them together in an array. I have developed the below script and find that I am getting only the last date value.
dates = ['1-12-21 @ 12:31 AM', '1-26-21 @ 09:45 AM', '12-14-20 @ 2:22 PM']
for(var i =0; i<dates.length;i++) {
var array = new Array();
array = dates[i].split('@');
var newDate = new Date(array[0] + " " + array[1]);
return newDate;}
I am getting the final value of 12-14-20 2:22 PM and not an array of dates. Instead I would like to get the array of date strings to date values.
I am new in javascript and so slowly catching up things.
question from:https://stackoverflow.com/questions/66049081/parse-array-of-dates-string-in-javascript