Sorting dates like 5/4/2009
Sorting dates like 5/4/2009
Hello, I am using datatables.net and loving it -- except I just noticed that if my column displays dates like 5/4/2009, it is not sorting them properly. I need to have the dates be 05/04/2009 instead to sort correctly. Is there any way around this? Thanks.
This discussion has been closed.
Replies
Date sorting can be a little tricky due to how Javascript's built in Date().parse() works. What it is probably best to do here is to put together your own sorting (and type detection if you want) functions.
Have a look at the following plug-in sorting and type detection functions with is for UK dates in the dd/mm/yyyy format:
http://datatables.net/plug-ins#sorting_uk_date
http://datatables.net/plug-ins#type_uk_date
These can be readily adapted for dates such as 5/4/2009.
Hope this helps,
Allan