0

I am using a datatable and adding the sort on the datetime column. When the datetime is formatted like this date 01/01/2021 10:11:20 AM the sorting works but when its formatted like this 01/01/2021 10:11:20AM it does not

I am using the moment.js a swell

erik
  • 55
  • 1
  • 1
  • 6
  • You can take a look at the approach shown here: [DataTables - How to sort by date](https://stackoverflow.com/a/68163742/12567365). In your case, the date format for moment.js will be `DD/MM/YYYY hh:mm:ss a` or `DD/MM/YYYY hh:mm:ssa` depending on whether you have a space between the seconds (`ss`) value and the AM/PM (`a`) value. – andrewJames Mar 24 '23 at 12:31
  • The above comment assumes you **do not** have both formats mixed in the same column. You should provide a [mre] with some code and sample data if the above approach does not help. There are also many other similar questions and answers here on SO for you to research. – andrewJames Mar 24 '23 at 12:31

0 Answers0