1

I am using jquery data-table. I want to show only date instead of complete date time in jquery data-table my sample code as below.

$(".example").DataTable({
            "ajax": {
                "url": "/FiscalYear/Get",
                "type": "Get",
                "datatype": "json"
            },
            responsive: true,
            "columns": [
                 { "data": "fiscalYearStart", "name": "fiscalYearStart", "width": "40%"  },
                 { "data": "fiscalYearEnd", "name": "fiscalYearEnd", "width": "40%" },
                 { "data": "fiscalYearFor", "name": "fiscalYearFor", "width": "10%" }
             ],
             "serverSide": "true",
             "processing": "true",
             "language": {
                 "processing": "Loading data..."
             }
        });

Date display as 2015-07-01T00:00:00, but I wish date should display as 2015-07-01

Usf Noor
  • 217
  • 1
  • 4
  • 16
  • Try using the `momentjs` library it's very useful for stuff like this. For more info check [THIS](https://stackoverflow.com/questions/41514750/how-to-format-date-displayed-in-datatable) out. – VTodorov Dec 15 '17 at 15:22

1 Answers1

0

Use columns.render option to generate content for a cell.

For example:

'columns': [
   {
      'render': function(data, type, full, meta){
         if(type === 'display'){
            data = data.substr(0, 10);
         }

         return data;
      }
   }
]

See this example for code and demonstration.

Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185