You can use the following sorting functions:
jQuery.fn.dataTableExt.oSort['string-case-asc'] = function(x,y) {
x = getTimeValue(x);
y = getTimeValue(y);
return x<y?-1:x>y?1:0;
};
jQuery.fn.dataTableExt.oSort['string-case-desc'] = function(x,y) {
x = getTimeValue(x);
y = getTimeValue(y);
return x<y?1:x>y?-1:0;
};
and getTimeValue () method:
function getTimeValue(x) {
var time = x.match(/(\d+)(?::(\d\d))?\s*(P?)/);
var h = parseInt(time[1],10) + (time[3] ? 12 : 0);
if(!time[3] && parseInt(time[1],10)==12) h = 0;
if(time[3] && parseInt(time[1],10)==12) h = 12;
return h * 60 + ( parseInt(time[2],10) || 0 );
}
Working example here
source
share