Date Format and Sorting Issue
Date Format and Sorting Issue
ashiquem01
Posts: 24Questions: 5Answers: 0
I am passing a date in the format "2023-07-30 00:00:00.000" from a JSON source,
but when displayed in the datatable, it appears as "/Date(1690660800000)/".
I am using using moment.min.js ,datetime-moment.js and " $.fn.dataTable.moment('DD/MMM/YYYY');"
to format the date as "30 Jun 2023".
I am looking for guidance on how to resolve this issue and achieve the desired date format in the datatable.
This question has an accepted answers - jump to answer
Answers
Try this for your column:
The following isn't really used for rendering but to tell the ultimate date sorting plugin what the date format is:
https://datatables.net/blog/2014-12-18
I successfully corrected the date format display issue,
but now I am facing a problem with sorting. The sorting treats the dates as alphanumeric values rather than actual dates. You're seeking a solution to ensure that the sorting is done in proper date format.
above image is on page load
After sorting ascending and descending.
Can you link to an example showing thebissue ao we can helpto debug it please?
Allan
Maybe one additional hint. This line of code must be executed BEFORE data table initialization.
@rf1234 Thanks
its worked
Thanks all for instant Support