Date is not rendering as Date

Date is not rendering as Date

istudent_learningistudent_learning Posts: 31Questions: 9Answers: 0

My table is getting /Date(1521706860000)/ as date.

 {
                    "data": "OrderedDate",
                    "name": "OrderedDate",
                    "render": function (data) {
                        console.log("Data: " + data);
                        var date = new Date(data);
                        console.log("Date: " + date);
                        return date;
                    }
                },

Answers

  • istudent_learningistudent_learning Posts: 31Questions: 9Answers: 0

    I used moment.js . Now it is working correctly.

    "render": function (data) {
    return moment(data).format("L");
    }

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    The date string you are getting is the string representation of a DateTime that .NET uses. Either you'd need to convert it before sending it to the client-side, or use Moment (or similar) as you have done.

    Allan

This discussion has been closed.