New to coding, help is appreciated. I have a jQuery data table which displays the buttons for Excel, PDF, Copy on top of the table and the drop down for page entries to show 10,25,50,100.
I have my date in US format (month-date-year), but the date isn't sorting properly from current date to oldest date:
01-09-2023
01-16-2023
03-05-2023
03-30-2023
03-31-2023
08-01-2023
11-10-2022
Please can you help me out to start the sorting as follows:
08-01-2023
03-31-2023
03-30-2023
03-05-2023
01-16-2023
01-09-2023
11-10-2022
I have tried this and the sorting isn't working for me:
<script type="text/javascript">
$(document).ready(function() {
var table = $('#tableID').DataTable({
columnDefs: [
{
targets: [0],
type: 'date-us',
}
],
order: [[0, 'asc']],
dom: 'Bfrtip',
buttons: [
'excel', 'pdf', 'copy'
]
});
});
</script>