How to format a column with date to different date format?
How to format a column with date to different date format?
loopers
Posts: 17Questions: 7Answers: 0
Currently fetching data like so:
columns: [
{"data": "number"},
{"data": "first_name"},
{"data": "blocked_at"},
]
and tried to add columnDefs
:
columns: [
{"data": "number"},
{"data": "name"},
{"data": "time"},
],
columnDefs: [ {
targets: 2,
render: $.fn.dataTable.render.moment( 'X', 'Do MMM YY' )
but it didn't work. Is there another way to do it?
Answers
looks like you are using this form of the datetime rnederer:
If its not working then its likely your source format doesn't match
X
. See the moment.js docs for formatting options. I put together a simple example showing your code snippet does work.http://live.datatables.net/sojovere/1/edit
In order to help we will need to see the problem with an example of your source data. Please provide a link to your page or a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin