0

I am trying to display some data in a datatable but Datetime in this case RegisterDate value not showing properly in jQuery data table. My Project is Asp.Net MVC. It shows as /Date(1542939575073)/ I do not know how to format my datetime in the jquery datatable function. Please help. Here is my code in my Index View ...

$(document).ready(function () {


            $("#myTable").DataTable({

                "processing": true,  
                "serverSide": true,  
                "filter": false,  
                "orderMulti": false,  
                "ajax": {
                    "url": "/Home/LoadEmployees",
                    "type": "POST",
                    "datatype": "json" 
                },
                "columns": [ 
                    { "data": "IdCardNr", "name": "IdCardNr", "autoWidth": true }, 
                    { "data": "RegisterDate","name": "RegisterDate", "autoWidth": true },
                    { "data": "PhonerNr", "name": "PhonreNr", "autoWidth": true },

                ] 
            });

        });

I know I must have kind of render some where inside but I do not know how to create it and where exactly to put it even if it should be right after "data" : "RegisterDate"

1

1 Answer 1

0

Put this code after "data": RegidterDate

 "render": function (mydata) {
                                var date = new Date(parseInt(mydata.substr(6)));
                                var month = date.getMonth() + 1;
                                return date.getDate() + "/" + month + "/" + date.getFullYear();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.