I am using jquery and bootgrid in an MVC ASP.NET project.
Using Entity Framework, I get the data I want to display in the grid which looks like this in the database:
1 Portal 2017-01-16 23:09:54.420 testFirstName testLastName testCompanyName
2 Portal 2017-01-14 14:37:33.750 John Doe Walmart
However, when I convert it to Json and pass it back to bootgrid, the JSON looks like
{"current":1,"rowCount":2,"rows":
[{"LeadId":1,"ScanDate":"\/Date(-62135571600000)\/","FirstName":"testFirstName","LastName":"testLastName","Company":"testCompanyName"},
{"LeadId":2,"ScanDate":"\/Date(-62135571600000)\/","FirstName":"John","LastName":"Doe","Company":"Walmart"}],"total":2}
The ScanDate value is incorrect.
In my bootgrid view I have set the column like so:
<th data-column-id="ScanDate" data-formatter="date">Date Sent</th>
And the data-formatter is as follows:
return (date == null ? "" : date.substring(0, 10));
The substring works because I only see the first 10 characters of the numbers from the above JSON response.
Why is the datetime coming out as numbers?
I even tried to convert the value to a date in JavaScript
var convertedDate = new Date(date);
But convertedDate is undefined and convertedDate.getDay / getHour() is NAN.
Any ideas?