How to sort table by dd/mm/yyyy
How to sort table by dd/mm/yyyy
davsev
Posts: 5Questions: 3Answers: 0
How do I sort table by dd/mm/yyyy format?
This is my code.
I added the moment cdn at the head right after the datatable files like this
!-- datatable -->
<link href="//cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet">
Searched around the site a bit but couldent find a working answer.
Sort works if the date format is yyyy.mm.dd
But it is not the required date format i need.
This is what i get now
any help would be great
tnx!
This discussion has been closed.
Answers
Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.
Information on how to create a test page, if you can't provide a link to your own page can be found here.
Thanks,
Allan
Thank you for the suggestion.
I have changed my code.
This is a fiddle of my table:
https://jsfiddle.net/davseveloff/v7oozsLv/2/
As you can see the sorting is not working very good.
At my website it is even worst. the sorting sorts firs the day (dd) than the month(mm) and finally the year(yyyy) for example 02/10/2015 wll appear before 10/2/2017.
As well I have a double arrow at the sort <th> that does not appear in the fiddle, What can couse it?
You have non-date data in the date column, which means that DataTables cannot correctly detect the date and thus is treating it as a string.
You would need to have a custom ordering plug-in that would strip out all the non-date information and just leave the date value.
Allan
Hey,
Thank you for your fast answer!
I worked it out
Nice one! Thanks for posting back with your solution.
Allan