0

I am trying to pull date in my data tables but for some reason the format of the data is not correct. I am getting the data from a stored procedure.

Original:

/Date(1575612000000)/

Expected Output:

01-15-2020

Code example:

 $(document).ready(function () {
    var mesa = $('.datatable').DataTable({
        filename: "LocationCodes",
        responsive: true,
        "bAutoWidth": false, // toggle this depending on how wide you want the table
        "ajax": {
            "url": "/controller/sp",
            "type": "GET",
            "datatype": "json"
        },
        "deferRender": true,
        "responsive": true,
        dom: 'Bfrtip',
        "bSort": false,
        buttons: [
            'excel', 'print'
        ],
        "columns": [
            { "data": "FileName" },
            { "data": "ProjectName" },
            { "data": "RecordInsertTime" }
        ]

Thanks, Minhal

Minhal
  • 85
  • 2
  • 17
  • 1
    This isn't a Datatables issue. The Date is formatted like that because that's how ASP.Net MVC returns dates in JSON (very annoyingly). See the duplicate I marked for how to handle them – Rory McCrossan Jan 15 '20 at 15:35
  • 1
    @RoryMcCrossan Thanks for pointing me to the right direction. – Minhal Jan 15 '20 at 15:50

1 Answers1

-1

is this what you want?

var d = new Date(1575612000000);
let month=d.getMonth()+1  // 12
let date=d.getDate()     // 6
let year=d.getFullYear() 
console.log(`${date}-${month}-${year}`)
deko
  • 1