european

tablesorter.js - supporting european dates

08.01.2009
 von Lukas Fischer
 | 0 Kommentare

We once ecountered the problem to sort by european dates like "12.01.2008". This is not possible with tablesorter.js by default.

The following source is inspired by http://gist.github.com/17385.

Add this to the tablesorter.js

<?php
ts
.addParser({
      
id'dates',
      
is: function(s) { return false },
      
format: function(s) {
          if (
== 'n/a') {
              return 
0;
          }
        var 
dateArray s.split('.');
        return 
"20" dateArray[2] + dateArray[1] + dateArray[0];
      },
      
type'numeric'
    
});
?>
Inhalt abgleichen