Problem with sorting dates DD/MM/YYYY
Problem with sorting dates DD/MM/YYYY
Mo45
Posts: 1Questions: 1Answers: 0
Hello there, i'm need some help with Date sorting. Cant sort date with DD/MM/YYYY mask.
Table header:
<table class="table table-striped table-responsive table-hover" id="apps" data-order='[[ 3, "dsc" ]]' data-page-length='25'>
Javascript:
<script type="text/javascript" src="<?=SITE_URL;?>js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<?=SITE_URL;?>js/dataTables.bootstrap4.min.js"></script>
<script type="text/javascript" src="<?=SITE_URL;?>js/moment.js"></script>
<script type="text/javascript" src="<?=SITE_URL;?>js/datetime-moment.js"></script>
<script type="text/javascript" src="<?=SITE_URL;?>js/tables.js"></script>
tables.js:
$(document).ready(function(){
$.fn.dataTable.moment( 'DD/MM/YYYY' );
$('#apps').DataTable( {
"columnDefs": [
{ "orderable": false, "targets": 0 },
],
"language":{
"sProcessing": "Зачекайте...",
"sLengthMenu": "Показати _MENU_ ігор",
"sZeroRecords": "Записи відсутні.",
"sInfo": "Ігри з _START_ по _END_ із _TOTAL_ ігор",
"sInfoEmpty": "Записи з 0 по 0 із 0 записів",
"sInfoFiltered": "(відфільтровано з _MAX_ записів)",
"sInfoPostFix": "",
"sSearch": "Пошук:",
"sUrl": "",
"oPaginate": {
"sFirst": "Перша",
"sPrevious": "Попередня",
"sNext": "Наступна",
"sLast": "Остання"
},
"oAria": {
"sSortAscending": ": активувати для сортування стовпців за зростанням",
"sSortDescending": ": активувати для сортування стовпців за спаданням"
}}
} );
});
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
This discussion has been closed.
Answers
you need to use the moment.js plugin for sorting:
https://datatables.net/plug-ins/sorting/datetime-moment
here is another discussion thread that might be helpful to get this set up:
https://datatables.net/forums/discussion/comment/116689/
It looks like the original post is actually using Moment and the Moment / DataTables plug-in.
@Mo45 - Can you link to the page in question for me so I can take a look at why it isn't working please?
Allan