0
I’m trying to create a date ordering 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 at the first value that gets like NaN
and when the ordination is done it is 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 am not able to locate the fault, and the other data has this format.