Sorting converted epoche dates
Sorting converted epoche dates
dg_datatables
Posts: 53Questions: 10Answers: 1
in Editor
Hi everyone,
the customer database provides "only" unix time seconds. I easily convert the unix time seconds to date with the render function:
{ data: "startdate>",
render: function (data, type, row) {
var dtst = "";
if (data > 0 && type === "display")
{
var mydate = new Date(data * 1000);
var myyear = mydate.getFullYear();
var mymonth = mymonth.getMonth() +1;
var myday = mydate.getDate();
if (mymonth< 10) { mymonth= "0" + mymonth; }
if (myday < 10) { myday = "0" + myday ; }
dtst = myday + "." + mymonth + "." + myyear ;
}
return dtst;
}
}
This works fine without using the moment.js
But i can't sort this column. Pressing on the sort buttons it has absoluty no effect.
Where am i wrong?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @dg_datatables ,
It's because you are always returning an empty string for the
sort
type - just returndata
as in this example here.Cheers,
Colin
Sorry - I'm blind!
I do not see a difference between your Code and mine. Your Code is working, but where is the difference?
Ha, very subtle change - it's the first line in the render function:
Oh yessssss
Thank's a lot for your help.