0

I am using datatable jquery api. I have a table which contains a date column, of which, data are in text format i.e. August 2nd, 2016. Here, the column is sorted in alphabetical order not according to the dates. What should I do ?

2 Answers 2

2

First, convert the dates using following line of code.

$timeStamp = strtotime('August 2nd, 2016');

Then, in the date column in your table, use this line of code.

<td data-order="<?php echo $timeStamp; ?>">August 2nd, 2016</td>
Sign up to request clarification or add additional context in comments.

Comments

2

try this in aoColumns;

        {
            sTitle: "Date", mData: "StartTime", mRender: function (data) {
                return data == null ? "" : '<span style="display:none;">' + new Date(data).getTime() + '</span>' + new Date(data).toLocaleString();
            }
        },

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.