0
Depending on the version or the files you use, it does not have the extension to sort by date.
To change, simply add the Datetable date-euro in your project and add the column that should be ordered, example:
$('#example').dataTable( {
columnDefs: [
{ type: 'date-euro', targets: 0 }
]
});
If you want to add only the code, the extension code is this:
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"date-euro-pre": function ( a ) {
var x;
if ( $.trim(a) !== '' ) {
var frDatea = $.trim(a).split(' ');
var frTimea = (undefined != frDatea[1]) ? frDatea[1].split(':') : [00,00,00];
var frDatea2 = frDatea[0].split('/');
x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1;
}
else {
x = Infinity;
}
return x;
},
"date-euro-asc": function ( a, b ) {
return a - b;
},
"date-euro-desc": function ( a, b ) {
return b - a;
}
} );
The camp guy must be like
String
, note that you are only considering the first digits. You should convert toDateTime
.– Pedro Camara Junior