Hello stworthy,
Thanks a lot for your reply. It works as expected.
The below code is my modified version which handles the date in dd/Mon/yyyy format as well.
var month_names = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
function dateSorter(date1, date2)
{
var toDate = function(str){
var parts = str.split(' ');
var dd = parts[0].split('/');
var hh = parts[1].split(':');
var date = "";
try{
date = new Date(dd[2],month_names.indexOf(dd[1].substring(0,3).toLowerCase()),dd[0],hh[0],hh[1],hh[2]); //converting month to lower case
}
catch(Ex){
date = new Date(dd[2],parseInt(dd[1])-1,dd[0],hh[0],hh[1],hh[2]); //subtracting one from month since months start from 0 in javascript
}
return date;
}
var d1 = toDate(date1);
var d2 = toDate(date2);
return d1.getTime()<d2.getTime()?-1:1;
}
Thanks & Regards,
Darrel.