I need to display date from controller to view through jQuery in MVC4 razor.But it just displaying correctly.

To display date I used the below code:
$.each(data, function (index, el) {
console.log(el);
for (i = 0 ; i <el.length; i++) {
tr = $('<tr class="eachitem" />');
td = $('<td>' + el[i]["ID"] + '</td>').appendTo(tr);
td1 = $('<td>' + el[i]["Date"] + '</td>').appendTo(tr);
td1 = $('<td>' + el[i]["status"] + '</td>').appendTo(tr);
tr.appendTo('table');
}
});
You need to parse the date string to a valid JavaScript date format. In order to do this use the following snippet from the answer in this question
var date = new Date(parseInt(value.replace("/Date(", "").replace(")/",""), 10));
After that, you will have a proper JavaScript date object which you can print in the format of your choice:
var stringDate = value.toLocaleString()
var stringDate = value.toISOString()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With