I'm trying to use the information on https://datatables.net/blog/2014-12-18 to make DataTables sort a column of dates which are in dd/mm/yyyy
format, e.g. 11/10/2018
(representing 11th October 2018).
I have included the following scripts - in this order:
- jquery.dataTables.1.10.7.min.js (locally hosted)
- //cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js
- moment.js (version 2.10.3, locally hosted)
My DataTables initialisation looks like this, as per the information on the URL above:
$(document).ready(function() {
$.fn.dataTable.moment( 'd/m/Y' );
$('#coursesTable').DataTable({"searching": false
});
});
But when I click the date heading in my #coursesTable
it gives the following output:
Obviously this is wrong because if the dates are ordered chronologically - most recent first - then 06/09/2017
should appear before 07/08/2017
- but that's not the order they appear in.
When ordering them the other way (oldest first) it gives the same error - i.e. the order is still incorrect:
I can't understand why this is occurring?
$.fn.dataTable.moment( 'dd/MM/YYYY' );
– Jitendra G206/02/2017
– Andy