jQuery DataTables plugin: Sort German date

I use jQuery DataTables plugin and my problem is that my German date does not get ordered correctly. It has the following format: dd.mm.YYYY HH:iih

Here comes my code:




    <table id="my-table">
      <th>Nr. </th>
      <td>27.08.2015 19:00h</td>
      <td>10.02.2016 14:00h</td>
      <td>07.12.2015 21:00h</td>

JS (updated, with ajax):

            "ajax": 'my_url',
            "columns": [
                {"data": "nr"},
                {"data": "date"},
                {"data": "name"}
                "autoWidth": false,
                "order": [],
                "fnCreatedRow": function( nRow, aData, iDataIndex ) {
                   var dateFull = aData.date;
                   var dateFullItems = dateFull.split(' ');
                   var dateDatum = dateFullItems[0];
                   var dateDatumItems = dateDatum.split('.');
                  var dateTime = dateFullItems[1];
                  var dateFormat = dateDatumItems[2] + '-' + dateDatumItems[1] + '-' + dateDatumItems[0] + 'T' + dateTime + ':00Z'; 

                  $(nRow).find('td:nth-of-type(2)').attr('data-sort', dateFormat);

What adjustments do I need to do in my JS for the sorting of date to work?

Answers 1

Related Articles