I can't get the ultimate plugin (https://datatables.net/blog/2014-12-18) work for my site.
I have a datetime column. The input for the column (called eisodos) from JSON is dd/MM/yyyy HH:mm:ss
(e.g. 31/10/2018 10:03:00
)
The field in SQL Server is Datetime. In query.php
, I FORMAT it to dd/MM/yyyy HH:mm:ss
and encode it to JSON.
If I FORMAT it to yyyy/MM/dd HH:mm:ss
it sorts fine in the Datatable plugin, but I want it to be displayed like dd/MM/yyyy HH:mm:ss
.
I have include both scripts (latest versions) :
<script src="bower_components/moment/min/moment.min.js"></script>
and
<script src="bower_components/moment/min/datetime-moment.js"></script>
I have checked everything.
The result I get when I sort is like this:
I have been searching two days and I can't find a solution.
Here is my code:
$(function ()
{
$.fn.dataTable.moment('dd/MM/yyyy HH:mm:ss');
var table = $('#example').DataTable(
{
ajax: {url: "query.php", dataType: "json", dataSrc: ''},
"columns": [
{"data": "eisodos"}
// I have also tried the following (column render) but nothing changed.
// "render": function(data, type, full) {return moment(data).format('dd/MM/yyyy HH:mm:ss');}
],
"language": {"url": "Greek.json"}
});
});