Changing Date / Time messes with column sorting
Changing Date / Time messes with column sorting
Aaron55
Posts: 2Questions: 1Answers: 0
Hello, currently my table column with date/time sort fine (format 2020-05-07T09:15:18). I want to change the format to UK gmt format, ive tried using moment.js by calling moment(data) with different formats but the column does not sort. any ideas please?
var eventsTable = $('#eventsTable').DataTable({
"ajax": {
"url": "https://localhost:5001/api/v1/ws4api/getallevents/" + ws4Id,
"dataSrc": "",
'beforeSend': function (request) {
request.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem('accessToken'));
},
"statusCode": {
401: function (xhr, error, thrown) {
// window.location.href = "Index.html"
return false
}
}
},
"pageLength": 50,
"destroy": true,
"order": [[3, "desc"]],
"columns": [
{ data: 'user' },
{ data: 'description' },
{ data: 'location' },
{
"data": 'time',
"orderable": true,
"render": function (data, type, row) {
return data;
}
},
{ data: 'auxInfo' }
]
})
This discussion has been closed.
Answers
I don't see your use of moment anywhere. We need to see that aspect of your code.
Please see below:
See if this blog about datetime sorting helps,
Kevin