I have a variable called dateArray with dates in it for example
[\"09/09/2009\", \"16/07/2010\", \"29/01/2001\"]
and I want to find the earlies
You can try with momentjs
library:
var dateArray = ["09/09/2009", "16/07/2010", "29/01/2001"],
format = 'DD/MM/YYYY',
minDate = moment(dateArray[0], format),
minDateKey = 0;
for (var i = 1; i < dateArray.length; i++) {
var date = moment(dateArray[i], format);
if (minDate > date) {
minDate = date;
minDateKey = i;
}
}
alert(minDateKey);