Search code examples
jquerysortingdatetimefiltertablesorter

tablesorter filtering a date format dd-mm-yyyy


I am using tablesorter to display date and I want the format of dd-mm-yyyy and I have this list of date.

Start Date
----------
08-05-2015
05-12-2015
24-07-2015
15-06-2015
17-05-2015

but when I sort it it will look like this form big to low value.

Start Date
----------
24-07-2015
17-05-2015
15-06-2015
08-05-2015
05-12-2015

is it possible that it will look like this?

Start Date
----------
05-12-2015
24-07-2015
15-06-2015
17-05-2015
08-05-2015

it can be ordered when I change the date forma into mm-dd-yyyy but is it possible for dd-mm-yyyy ?

I tried this code but seems nothing happen

$('#mytable').tablesorter({
   sortList: [[0,0],[2,0]], 
   dateFormat : 'dd-mm-yyyy',
});

Solution

  • I can't tell if you're using the original tablesorter (v2.0.5) or my fork of tablesorter, so I'll answer for both:

    • v2.0.5 - The only dateFormat options that are available are:

      • "us"
      • "uk"
      • "pt" (only available in the master branch)
      • "dd/mm/yy" or "dd-mm-yy"
    • tablesorter fork dateFormat option (currently v2.21.4)

      • "mmddyyyy" (default)
      • "ddmmyyyy"
      • "yyyymmdd"