简体   繁体   中英

How to sort date column in Datatables framework?

I'm trying to make a date column sortable by date but it only sorts by the day.

URL to my example: https://aetos-us1.infinitybht.app/store/81113d0060/?ui=dashboard ( click on "Requests", then sort the "Creation Date" column.)

The js code I'm using:

$.fn.dataTable.moment( 'ddd.mm.YYYY HH:mm' );

$('#requests_table').DataTable( {
    "columnDefs": [
            { "type": "datetime-moment", targets: 6 }
        ],
)}

Thanks for helping me in this.

You can try this

Ref: http://jsfiddle.net/mlotfi/6gzpnjgx/

var table = $('#example').DataTable({
    columnDefs : [
        { type: 'time-date-sort', 
          targets: [6],
        }
    ],
    order: [[ 6, "desc" ]]
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM