datatable date sorting dd MMM yyyy ; hh:mm:ss
datatable date sorting dd MMM yyyy ; hh:mm:ss
Hi,
I am using DataTables plugin.
I am displaying a bunch of columns in the datatables. I ahve applied column sorting for all the columns. The soring is working perfectly fine for all the columns except for the column in which date is displayed in the format dd MMM yyyy ; hh:mm:ss
This is being considered as a string and the column is getting sorted as per that assumption.
For example,
Lets say the column contains the following values
20 Feb 2015 ; 17:20:00 hrs
09 Feb 2015 ; 10:36:48 hrs
21 Jan 2015 ; 17:20:00 hrs
If i sort the column in ascending order, the result is as follows
09 Feb 2015 ; 10:36:48 hrs
20 Feb 2015 ; 17:20:00 hrs
21 Jan 2015 ; 17:20:00 hrs
but the correct result should be
21 Jan 2015 ; 17:20:00 hrs
09 Feb 2015 ; 10:36:48 hrs
20 Feb 2015 ; 17:20:00 hrs
Please provide any solution to solve this issue.
Thanks in advance.
This question has an accepted answers - jump to answer
Answers
Hi @walterhunk,
I still didn't faced this problem directly but
perhaps this page could help you
http://datatables.net/blog/2014-12-18
Cheers
Hi @razorblade,
Thanks for the reply. Will incorporate this in my code and check how this turns out.
This is example of the scenario i mentioned
http://live.datatables.net/susipuhi/1/
Thank you.!
@Razorblade's suggestion is probably the best option. As noted in the blog post
Date.parse()
in browsers (which is DataTables' default date/time sorting option, since anything else needs large amounts of code that I don't want to put into the core library) is very limited and worse, varies significantly between browsers!Plug-ins are the best way unless you are working with ISO8601.
Allan
@allan and @razorblade
The method mentioned by in http://datatables.net/blog/2014-12-18 is not working for the date, time format dd MMM yyyy ; hh:mm:ss which I am using
Thanks.
Should do as long as you tell the plug-in what your date format is. Can you link to your page that is showing the problem please.
Allan