http://mottie.imtqy.com/tablesorter/docs/
Set the date format. Here are the available options. (Changed v2.0.23).
- "mmddyyyy" (default)
- "ddmmyyyy"
- "yyyymmdd"
In previous versions, this option was set to "us", "uk" or "dd / mm / yy". This setting has been changed to better suit date formats. It will only work with four-digit years!
The sorter must be set to "shortDate", and the date format can be set in the "dateFormat" option or set for certain columns in the "headers" option. See the demo page to see how it works.
$(function(){ $("table").tablesorter({ dateFormat : "mmddyyyy", // default date format // or to change the format for specific columns, // add the dateFormat to the headers option: headers: { 0: { sorter: "shortDate" }, // "shortDate" with the default dateFormat above 1: { sorter: "shortDate", dateFormat: "ddmmyyyy" }, // day first format 2: { sorter: "shortDate", dateFormat: "yyyymmdd" } // year first format } }); });
Individual columns can be changed by adding the following (they all do the same thing), set in order of priority (Changed v2.3.1):
- Data jQuery data-dateFormat = "mmddyyyy".
- metadata class = "{dateFormat: 'mmddyyyy}. This requires the metadata plugin.
- Header Header Headers: {0: {dateFormat: 'mmddyyyy}}.
- header class name class = "dateFormat-mmddyyyy". General option dateFormat.
In my case, I used
$("#myTable").tablesorter({dateFormat: "uk"})
for version.
source share