How to sort date time columns || Como ordenar la columna por fecha y dia
How to sort date time columns || Como ordenar la columna por fecha y dia
I am trying to get sorting column in datetime by following below link but it is not working for me.
https://datatables.net/blog/2014-12-18
In this case:
$.fn.dataTable.ext.errMode = 'none';
$.dataTable.moment('MM/dd/yyyy HH:mm:ss');
format date:
MM/dd/yyyy HH:mm - 28/12/201 08:00
https://ibm.com/support/knowledgecenter/es/SSHEB3_3.3.2/com.ibm.tap.doc_3.3.2/loc_topics/c_custom_date_formats.html
$(document).ready(function () {
$.fn.dataTable.ext.errMode = 'none';
$.fn.dataTable.moment('dd/MM/yyyy HH:mm');
let TableList = $('#example')
table = TableList.DataTable({
autoWidth: true,
dom: "Bfrtip",
lengthChange: true,
ordering: true,
pageLength: 12,
responsive: true,
sAjaxDataProp: "",
select: true,
ajax: {
url: '{% url 'api_mostrar_programacion_nave' %}',
type: "POST",
data: {
csrfmiddlewaretoken: document.getElementsByName('csrfmiddlewaretoken')[0].value
}
},
});
});
help me please !
Replies
Take a look at this please:
https://datatables.net/forums/discussion/comment/122744
and this:
https://datatables.net/forums/discussion/comment/122660
@rf1234 ty for u answer. im from Peruvian and using google translate for the publications and my lenguage is Spanish.
I'm trying this code.
Am I having problems with the format of the dates or am I putting the code wrong? (Check photo format date)
Translate google, sorry
probably the same issue that the Italian guy had in the second example above. The date format that you would like is 20/12/2016 which is "DD/MM/YYYY" and not "dd/MM/yyyy"
Take a look at the Spanish locale file please. In that file you find this:
And if you take a look at this: https://momentjs.com/
and scroll down and select "Spanish" you'll see what those longDateFormats will be formatted to. It is actually this:
As you can see the format that you desire is not on that list which means the locale file won't really help you at all because what you need is actually a combination of longDateFormats L and LT. You don't want LLLL.
I would try the following (without using the locale file):
I see you've edited your question. So format LLLL is gone
This combination doesn't really make sense by the way:
because if you are not using the date formats of the locale files there is no need to specify a locale. This is only useful if you are using those formats and have multiple languages on your site.
So just use
and you should be ok. No need for the locale file then.
@rf1234 TY, its great, but it's very confusing all this format.
What is the difference?
$.fn.dataTable.moment('dd/MM/yyyy HH:mm');;
$.fn.dataTable.moment('DD/MM/YYYY H:mm'); (This is correct)
Ty @rf1234
well Javascript is case sensitive ... I didn't invent this stuff, mate We all have to live with it.
Yes, u have reason. Thank you very much for the information.