• Resolved foscone

    (@foscone)


    Hi, is there a way to sort date-time column?
    If I try it sorts like:
    01/11/2017 18:22
    01/12/2017 05:40
    01/12/2017 20:17
    02/11/2017 10:31
    02/11/2017 16:18
    02/11/2017 17:38
    02/12/2017 23:55
    03/11/2017 16:07
    03/11/2017 20:44
    03/11/2017 22:01

    This dates are generated in php foreach:

    <table class="tablesorter {sortlist: [[0,0]]}">
     <thead>
      <tr><th>Date</th></tr>
     </thead>
     <tbody>
      <?php
      foreach ( $sent_list as $lista ) { ?>
       <tr>
        <td>
         <?php
         $date= new DateTime($lista[ts]);
         echo $date->format('d/m/Y H:i');
         ?>
        </td>
       </tr>
      <?php } ?>
     </tbody>
    </table>

    I can’t share link because is in a private area, sorry.
    Thanks
    Fosco

    • This topic was modified 7 years, 1 month ago by foscone.
Viewing 4 replies - 1 through 4 (of 4 total)
  • I had the same problem and solved in modifying the jquery.tablesorter.min.js file where I changed the date format parameter as follow :

    dateFormat:”ddmmyyyy”

    This parameter is located near the begining of the php file.

    You may also be interested in another change if you want to sort numeric value with comma as decimal separator.

    Change the follwing parameter :

    usNumberFormat:!1

    I hope this can help.

    Plugin Author Farhan Noor

    (@farhannoor)

    Hi,

    To make your date columns sortable, add this class in your Date column head dateFormat-dd/mm/yyyy

    You should do it like this <th class="dateFormat-dd/mm/yyyy">Date</th> You can change date format according to your own need.

    Cheers. Happy coding!

    Not sure you shoud include the “/” in the dateFormat. ddmmyyyy should work

    Thread Starter foscone

    (@foscone)

    Thank you, also for me <th class="dateFormat-ddmmyyyy">Date</th> works.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Date sort’ is closed to new replies.