After writing a GET API, I am trying to display some records in a data table. However, when retrieving the records in JSON format, the date values are coming in this format: "/Date(1498849454000)/". How can I convert this into "2017-04-11 02:09" format? The actual stored data is in the correct format of "2017-04-11 02:09:17.000". The data type is datetime.
Sample Data
{"data":[{"updtd_date":"\/Date(1498849454000)\/","usecase":"watertank","id":1026,"sms":"Alert: Tank is Full at 01/07/2017 12:33:51 AM ]"},
Code
<script>
$(document).ready(function () {
$('#myTable').DataTable({
"ajax": {
"url": "url",
"type": "GET",
"datatype": "json"
},
"columns" : [
{ "data": "updtd_date", "autoWidth": true },
{ "data": "usecase", "autoWidth": true },
{ "data": "id", "autoWidth": true },
{ "data": "sms", "autoWidth": true }
]
});
});
</script>
<table id="myTable">
<thead>
<tr>
<th>Time</th>
<th>Use Case</th>
<th>Sl no</th>
<th>SMS</th>
</tr>
</thead>
</table>
Controller
public ActionResult getSMS()
{
using (smartpondEntities dc = new smartpondEntities())
{
var data = dc.sms.OrderByDescending(a => a.id).ToList();
return Json(new { data = data }, JsonRequestBehavior.AllowGet);
}
}