I'm trying to create a date order in a dataTable
where the format will be dd-MM-aaaa hh:MM:ss
.
The code below even works the problem that it gives some conversion error always in the first value that stays as NaN
and when it is done the ordering stays fixed.
code:
jQuery.fn.dataTableExt.oSort['uk_date-pre'] = function (a) {
a = a.replace("-", "/").replace("-","/");
// a = a.slice(0, -2) + '' + a.slice(-2);
var date = Date.parse(a);
return typeof date === 'number' ? date : -1;
}
jQuery.fn.dataTableExt.oSort['uk_date-asc'] = function (a, b) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
}
jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function (a, b) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
I can not find the fault, the other data has this format.