Sorting by date doesn't work

Sorting by date doesn't work

loopersloopers Posts: 17Questions: 7Answers: 0
edited March 2022 in Free community support

When I click the little arrow on the column header of the date, it doesn't really sort it by date. I assume that's because it's a string? For example, after clicking the sorting arrow, this is how the dates show up:

02-03-2022 10:54:20
02-03-2022 11:46:31
07-03-2022 13:50:21 
07-03-2022 13:51:15 
07-03-2022 13:54:52
07-03-2022 14:03:52
07-03-2022 14:04:44
08-03-2022 09:09:02

unsorted at all.

What should I do?

Answers

  • kthorngrenkthorngren Posts: 21,351Questions: 26Answers: 4,955

    See this datetime sorting blog for the recommended way to sort dates.

    Kevin

  • loopersloopers Posts: 17Questions: 7Answers: 0

    thanks. do you know where to place the moment js code when using Yajra with Laravel?

  • kthorngrenkthorngren Posts: 21,351Questions: 26Answers: 4,955

    Not specifically but I suspect in the same area you have datatables.js.

    Kevin

Sign In or Register to comment.