Sorting dates with tablesorter plugin
Hi folks, this one is driving me mad!
I have a table of data that I was hoping to sort using the
tablesorter plugin but I'm finding that it doesn't work at all on date columns. I wonder if it's because I'm working with UK dates... here's my call to the plugin:
- <script type="text/javascript">
- $(document).ready(function() {
- //Attach the LoadUsers template event to the link/button
- $("#UsersTable").tablesorter({
- dateFormat: 'dd/mm/yyyy',
- headers:
- {
- 0: { sorter: "text" },
- 1: { sorter: "shortDate" } //buggy
- }
- });
- });
-
- </script>
... and here's my html table, if you want to try with my data:
- <table class="tablesorter" id="UsersTable" style="width:50%">
- <thead>
- <tr>
- <th>Full name</th>
- <th>Last login</th>
- </tr>
- </thead>
- <tbody>
- <tr id="85">
- <td>Alison Auburn</td>
- <td>20/07/2007</td>
- </tr>
- <tr id="45">
- <td>Andy Amber</td>
- <td>03/07/2007</td>
- </tr>
- <tr id="2176">
- <td>Barry Blue</td>
- <td>06/06/2007</td>
- </tr>
- <tr id="60">
- <td>Charis Gold</td>
- <td>31/05/2007</td>
- </tr>
- <tr id="830">
- <td>Gemma Grey</td>
- <td>16/07/2007</td>
- </tr>
- <tr id="4122">
- <td>Johnny Green</td>
- <td>06/05/2009</td>
- </tr>
- <tr id="244">
- <td>Jonathan Brown</td>
- <td>19/07/2007</td>
- </tr>
- <tr id="86">
- <td>Kathleen White</td>
- <td>13/12/2006</td>
- </tr>
- <tr id="94">
- <td>Kerry Cream</td>
- <td>05/07/2007</td>
- </tr>
- <tr id="266">
- <td>Lyndsay Black</td>
- <td>20/07/2007</td>
- </tr>
- <tr id="23">
- <td>Maria Yellow</td>
- <td>22/06/2007</td>
- </tr>
- <tr id="27">
- <td>Maria Red</td>
- <td>17/04/2007</td>
- </tr>
- <tr id="4123">
- <td>Boris Brown</td>
- <td>08/05/2009</td>
- </tr>
- </tbody>
- </table>
I've attached two screen dumps, to show that not only is it wrong, but the results are differently wrong across browsers.
Like I say, it might be a UK date thing but I can find any docs on this at all.
Any help is appreciated!