I have a datatable up and running and at the moment I have defined the date format manually by adding
$.fn.dataTable.moment("DD.MM.YYYY");
before defining my datatable itself:
var myTable = $('#authors').DataTable({
"paging": false,
"ordering": true,
"order": [2, "desc"],
"info": false,
"stateSave": true,
"responsive": true,
"columnDefs": [
{ targets: "noSort", orderable: false }
]
});
As you can see, we are currently using the German date format. But it can be the case that we have to use other formats later that year.
Is there a way to detect the value of a given date column automatically so that I can sort that column correctly? Or will I always have to define the date format manually?
What I want to have is kind of a dynamic version of the line
$.fn.dataTable.moment("DD.MM.YYYY");
It should detect, "oh, the value in that column is '29.04.2019', this is a German date format, defined as dd.mm.yyyy" and use this format for further sorting.
Or if the value is "04/29/2019" instead, this should be recognized as a US date format, using 'mm/dd/yyyy' for sorting.
from jQuery DataTables: is there a way to detect date format automatically?
No comments:
Post a Comment