Date format and sorting: How do I sort my time outputs with DataTables?
Date format and sorting: How do I sort my time outputs with DataTables?
hAtul89
Posts: 12Questions: 7Answers: 0
When inserting a time string, for example: "96:43" [h:m]
and sort the column I get something like this:
which doesn't make any sense - seems like it's sorting by first number and not by "time".
How do I sort my time outputs with datatables?
This discussion has been closed.
Answers
Hi @hAtul89 ,
Use the DataTime plugin for this.
Cheers,
Colin
@colin
I might have not been so clear. I am not using any dates. just minutes and seconds (as a counter)
^
What i have displayed is the string output of this function. just taking a number by minutes and turning it to hh:mm as in my screenshot.
You may want to consider using
columns.render
and orthogonal data. You could use your seconds value for the data of the column then incolumns.render
use the above function for thedisplay
and 'filter` types.Or you can look through the other sorting plugins and maybe adapt one of them for your solution. Maybe the
time
plugin can be adapted.Kevin
@colin I tried to understand the blog post you shared and i just don't get how it should work with my code.. this is how it looks like on my end:
Hi @hAtul89 ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin