sort date/time

sort date/time

tpepernictpepernic Posts: 12Questions: 0Answers: 0
edited April 2012 in General
Currently I use a time format I generate with php with a timezone offset:

[code]date('Y-m-d g:i A',strtotime($utc)+$timezone_offset*60*60)[/code]

This gives this example format: 2012-04-07 9:58 AM. Datatables does not sort this well. I'm not married to this format it doesn't really matter to me. What format in my php code can I use that Datatables will sort by default (without having to create a custom sorting plugin)?

Replies

  • tpepernictpepernic Posts: 12Questions: 0Answers: 0
    Just wondering if anyone else has run into this? I thought this was better but it looks to suffer from similar problems
    [code]date('d M Y H:i:s',strtotime($utc)+$timezone_offset*60*60);[/code]
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    DataTables will chronologically sort any date format that is automatically detected by Date.parse ( https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse ) - i.e. RFC2822 or ISO 8601 dates.

    For any other format you would need to use a sorting plug-in, of which there are a number of various date formats: http://datatables.net/plug-ins/sorting . Or alternatively you could use the technique described in this article: http://datatables.net/blog/Orthogonal_data

    Allan
This discussion has been closed.