date and time field not showing as day/month/year time

date and time field not showing as day/month/year time

jbcom41@outlook.comjbcom41@outlook.com Posts: 4Questions: 3Answers: 0

Hi, I am a compelte Knowbie so excuse my quesstion if it comes across dumb, i have created a small web application at the folliwng https://wireme.co.uk/BookList but i can not get the date to display correctly, not sure what i am doing wrong, please see my jason code below

function loadDataTable() {
dataTable = $('#DT_load').DataTable({
"ajax": {
"url": "/api/book",
"type": "GET",
"datatype": "json"
},
"order": [[0, "desc"]],
"columns": [
{ "data": "po", "width": "20%" },
{ "data": "creator", "width": "20%" },
{ "data": "company", "width": "20%" },
{ "data": "date", "width": "20%" },
{
"data": "po",
"render": function (data) {
return <div class="text-center"> <a href="/BookList/Edit?id=${data}" class='btn btn-success text-white' style='cursor:pointer; width:70px;'> Edit </a> &nbsp; <a class='btn btn-danger text-white' style='cursor:pointer; width:70px;' onclick=Delete('/api/book?id='+${data})> Delete </a> </div>;
}, "width": "40%"
}
],
"language": {
"emptyTable": "no data found"
},
"width": "100%"
});
}

Answers

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394
    edited August 2020

    i can not get the date to display correctly

    What do you mean by "correctly"? What date/time format do you want?

    EDIT: Just realised the clue is in the thread title.
    You could create another column render function, or have a look at using moment.js
    https://datatables.net/blog/2014-12-18#Operation

This discussion has been closed.