HOW TO FORMAT DATE TYPE dd / MM / YY
HOW TO FORMAT DATE TYPE dd / MM / YY

I am using datatable extracting data from an ajax file passing data with json and in the date column it comes out 2015-10-22T00: 00: 00.000000Z and I want it to come out 10/22/2015
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
See if the Datetime renderer does what you want.
Kevin
kthorngren
Thank you very much, could you please explain to me what columnDefs and target mean
Please see the docs for
columnDefs
andcolumnDefs.targets
. If you are usingcolumns
you can just add the renderer to the appropriate column without needing to usecolumnDefs
.Kevin
kthorngren
Thank you very much, I have this:
.......').dataTable( {
columns:[
{data:'ID_XX'},
{data:'DesXXx'},
{data:'DATEXXXxx'},
],
columnDefs: [ {
targets: 2,
render: $.fn.dataTable.render.moment( 'Do MMM YYYY' )
} ]
.......
BUT it still doesn't work for me, it shows me in the column the message of "Invalid date"
The datetime.js docs show there is the possibility of using up to 3 parameters. You might need to provide the source format, for example:
$.fn.dataTable.render.moment( from, to );
To learn more see the moment.js docs.
Kevin
Thanks Kevin, check the documentation and I found this:
moment().format(); // 2020-10-26T10:32:56-04:00
this would be the date that I have to format 2015-10-22T00: 00: 00.000000Z
then I can't find in the documentation what the source format would be or how I would have to use it .., I did it this way:
columns:[
{data:'ID_ActividadSis'},
{data:'DescActividadSis'},
{data:'FechActividadSis',
type: 'date',
render: $.fn.dataTable.render.moment('YYYY-MM-DDTHH:mm:ssZ','YYYY/MM/DD' )
},
BUT it still doesn't work for me
Not sure if you found the moment.js format docs. Looks like you need to add the fractional second of
S
. Maybe something like this:YYYY-MM-DDTHH:mm:ss.SSSSSSZ
I have verified that format fully matches what you have. If you still need help please build a simple test case so we can help define the moment formats.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I change http://live.datatables.net/decudehu/1/edit
<tr>
<td>Ashton Cox</td>
<td>Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2015-10-22T00:00:00.000000Z</td>
<td>$4,800</td>
</tr>
that row its like me, but not working
http://live.datatables.net/decudehu/1/edit
Ashton Cox Technical Author San Francisco 66 2015-10-22T00:00:00.000000Z $4,800
using a test case put all my dates in the table according to the following link
http://live.datatables.net/decudehu/1/edit
and I have commented on the way I am trying to format the date
$(document).ready( function () {
var table = $('#example').DataTable( {
// columnDefs: [ {
// targets: 4,
// render: $.fn.dataTable.render.moment('YYYY-MM-DDTHH:mm:ss.SSSSSSZ','YYYY/MM/DD' )
// } ]
} );
} );
sorry this is the modified
http://live.datatables.net/decudehu/1/edit
Can't explain why but it seems to work with using only 4
SSSS
instead o 6. For example:http://live.datatables.net/luviyuzi/1/edit
Kevin
OMG
ITS WORKING NOW 
THANKS THANKS THANKS