Date format is not being correctly detected

Date format is not being correctly detected

justStevejustSteve Posts: 49Questions: 8Answers: 1
edited January 2016 in DataTables 1.10

I have a data coming from the server where a date column is of form: 1/25/2015 12:45:10 AM but is rendered in the table as /Date(1422168310723)/

I've implemented the Moment plug in and believe I'm correctly initializing because inserting debug alert:

    $.fn.dataTable.moment = function (format, locale) {
        alert(format);

will return 'M/D/YYYY'.

My ajax:

            "ajax": {
                "type": "POST",
                "url": '/admin/UsersDataHandler',
                "contentType": 'application/json; charset=utf-8',
                'data': function (data) {
                    data.affiliateId = DU.affiliateId;
                    return data = JSON.stringify(data);
                }

serverSide and processing both set to true;

To keep it simple, i'm not currently posting an entry for the column in "aoColumnDefs": and only use { 'data': 'DateCreated', "searchable": false } in the "columns" collection.

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin

    Can you link to the page showing the issue please. I don't quite understand why DataTables would show a Microsoft date format if the server-side is actually returning a sensible date string.

    Allan

  • justStevejustSteve Posts: 49Questions: 8Answers: 1
    Answer ✓

    I tweaked my server-side code with: OrderDate.ToShortDateString(); and the problem resolved. Thanks

This discussion has been closed.