Date sorting problem with jQuery Tablesorter

Viewed 40470

I am trying to sort a table which has column like 2009-12-17 23:59:59.0. I am using below to apply sort

$(document).ready(function() { 
    $("#dataTable").tablesorter();  
});

But its not working for the dates of format yyyy-mm-dd. Can any one suggest how can i apply this format for sorting?

8 Answers

With TableSorter 2 you can simply use the data-text attribute to store the alternative sort value. I'm doing so in PHP like this to get time considered when sorting, but only show date in the table:

<td data-text="<?php xecho(date_format($date, "Y-m-d H:i:s")); ?>">
    <?php xecho(date_format($date, "F d, Y")); ?>
</td>

No formatting or parsing necessary.

Related