Ich füge Zeit in die Datenbank ein und hole die Datetime aus der Datenbank. Beim Einfügen des Werts wird das Einfügen wie folgt eingefügt: "2017-04-11 02: 09: 00.000", aber bei der Anzeige in der Tabelle wird das wie folgt angezeigt/Datum (1486495036000) /.unerwartetes Datumsformat kommt wie folgt/Datum (1486495036000)/in Tabelle
Code
SqlCommand cmd = new SqlCommand("insert into sms values('" + today + "','" + usecase + "','" + smsdata + "')", con);
Datenbank Abtastdaten
updtd_date usecase id sms
2017-04-11 02:09:00.000 watertank 1 Tank filled
Datentyp updtd_date in Tabelle small
Controller
public ActionResult getSMS()
{
using (dbEntities dc = new dbEntities())
{
var data = dc.sms.OrderByDescending(a => a.id).ToList();
return Json(new { data=data }, JsonRequestBehavior.AllowGet);
}
}
view
<script>
$(document).ready(function() {
$('#myTable').DataTable({
"ajax": {
"url": "/WaterLevel/getSMS",
"type": "GET",
"datatype": "json"
},
"columns": [
{ "data": "updtd_date", "autoWidth": true },
{ "data": "usecase", "autoWidth": true },
{ "data": "id", "autoWidth": true },
{ "data": "sms", "autoWidth": true }
]
});
});
</script>