Closed mverma16 closed 8 years ago
So I tried to solve the issue using "aoColumnDefs" in setOptions().
I converted the date I was fetching from database into javascript date format before rendering the data in to column.
here's the snippet of the code I used
->setOptions('aoColumnDefs',array(
array(
'render' => "function ( data, type, row ) {
var t = row[6].split(/[- :,/ :,. /]/);
var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
<!-- -->
var dtf= '$date_time_format';
if(dtf==1) {
dtf = 'D/MMM/YYYY hh:mm:ss A';
} else if(dtf==2) {
dtf = 'D MMM, YYYY hh:mm:ss A';
} else if(dtf==3) {
dtf = 'D-MMM-YYYY hh:mm:ss A';
} else if(dtf==4) {
dtf = 'MMM/D/YYYY hh:mm:ss A';
} else if(dtf==5) {
dtf = 'MMM D, YYYY hh:mm:ss A';
} else if(dtf==6) {
dtf = 'MMM-D-YYYY hh:mm:ss A';
} else if(dtf==7) {
dtf = 'YYYY/MMM/D hh:mm:ss A';
} else if(dtf==8) {
dtf = 'YYYY, MMM D hh:mm:ss A';
} else if(dtf==9) {
dtf = 'YYYY-MMM-D hh:mm:ss A';
}
return moment(d).format(dtf);
<!-- //return d; -->
}",
'aTargets' => array(6))
))
Hope this will help you, if you are looking for the solution for this issue.
Hello, I am trying to implement datatable where I want records to be sort by last updated record.
Code in my blade file looks like this
And controller function is
I am sorting the data before rendering table by 'Last' which is last updated_at date column.
Ordering is successful in "mm/dd/yyyy" and "yyyy/mm/dd" format but in "dd/mm/yyyy" ordering is getting failed.
While sorting in ''mm-dd-yyyy" format it works fine
But sorting in dd-mm-yyyy it sorts incorrectly
Can you help me to implement sorting correctly in all date formats. TIA