Set DataTable column data type to date

1

I have a DataTable that displays values coming from a SQL database, like this:

<table id="tabelaLogs">
    <thead>
        <tr>
            <th>Código</th>
            <th>
                Data
            </th>
            <th>
                Tipo
            </th>
            <th>
                Descricao
            </th>
            <th>
                Criador
            </th>
            <th>
                Computador
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@Html.DisplayFor(modelItem => item.codigoLog)</td>
                <td>
                    @Html.DisplayFor(modelItem => item.dataHora)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.tipo)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.descricao)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.criadoPor)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.computador)
                </td>
            </tr>
        }
    </tbody>
</table>

As you can see column number 1 (Starting counting from 0), it is a column that displays a value coming from DB that is a Date, in the format that the date is seen on my PC, in the American format, MM / DD / YYYY HH: MM: SS A.

However, when passed to the DataTable, the Date type is passed as String. If I run this command in the Chrome console: CallLogs.column (1) .data [0], it returns this: "17/8/2017 21:35". A String.

I wanted to return a variable of type Date, like this: Thu Aug 17 2017 21:35:00 GMT-0300 (E. South America Standard Time)

So that I can filter the table records that have date, between two others.

I have already started my DataTable with this code, but still the data type of the column continues as String.

tabelaLogs = $("#tabelaLogs").DataTable({
                "columnDefs": [
                    { "sType": "date", "targets": 1 }
                ]
            });

Can anyone help me?

    
asked by anonymous 21.08.2017 / 02:02

0 answers