Date Format
Date Format
ridgeandgable
Posts: 3Questions: 2Answers: 0
I have my datatable working but I'm trying to change the date to the dd/mm/yyyy format.
If I use this
moment.updateLocale(moment.locale(), { invalidDate: "Invalid Date Example" });
var table = $('#test').DataTable({
columnDefs: [{
targets: 3,
render: $.fn.dataTable.render.moment('DD/MM/YYYY' ),
}],
});
} );
it works perfectly, but when I put everything together, it doesnt
<script>
$(document).ready( function () {
$('#test').DataTable({
paging: false,
searching: true,
scrollY: 600,
"order": [[ 6, "asc" ]],
moment.updateLocale(moment.locale(), { invalidDate: "Invalid Date Example" });
var table = $('#test').DataTable({
columnDefs: [{
targets: 3,
render: $.fn.dataTable.render.moment('DD/MM/YYYY' ),
}],
});
} );
</script>
Also, I have multiple date fields on this table (3 & 6), how do I make it work with more than 1?
Answers
It is unclear what you trying to achieve.
And I don't know what this is supposed to do:
Let's assume this is only about rendering ...
It looks like line 8 should be moved to between 2 and 3 like @rf1234 suggests. @ridgeandgable you should be getting a Javascript syntax error in the browser when trying to run that code.
Allan