MySQL TIMESTAMP field not sorting correctly?
MySQL TIMESTAMP field not sorting correctly?
NJWebDesign
Posts: 7Questions: 3Answers: 0
Is there a known issue with sorting TIMESTAMP fields? All other fields are sorting correctly.
Thank you.
NJ
This discussion has been closed.
Answers
Nope, but you probably want to define the format if it's non-standard, something like this or this.
Colin
Thank you for those examples Colin.
I was outputting my dates, in PHP, as d/m/Y H:ia and that simply doesn't work so I removed H:ia and, using your example, it's working now.
I should add that I also wasn't, previously, calling these two scripts:
https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js
https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js
I note that whilst it is working, it's not ordering by the full timestamp - it's just ordering by dd/mm/yy. Is there a way to get it to take into account the hours, minutes, seconds?
Much appreciated.
NJ
The Moment Format docs provide the strings needed to match your date/time format.
Kevin