Sorting Date column that includes time zone will not work

Sorting Date column that includes time zone will not work

YoDavishYoDavish Posts: 119Questions: 45Answers: 3

Is there anyway to sort this date column that includes the time zone? Example of it is below. If I remove the time zone i.e. "US/Central" then it does work fine. However, it was requested to include it.

2022-05-18 09:23:47 PM US/Central
2022-05-18 09:22:11 PM US/Central

I could just move the time zone into a new column but as of now, the client perfers it all in one.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 16,790Questions: 25Answers: 3,979
    Answer ✓

    If you have Datatables 1.12 then see this doc. If using a previous version see this blog.

    Kevin

  • YoDavishYoDavish Posts: 119Questions: 45Answers: 3

    @kthorngren Thanks, I have 1.10 version of DT. I've tried the blog link and added:

    ```columnDefs: [
    { targets: 6, type: 'date' }
    ],

    as well as:

    $.fn.dataTable.moment('YYYY-mm-dd HH:mm:ss tt');

    However when I have the time zone include i.e. "US/Central" or "US/eastern" the order is off. When i remove the time zone, the order appears correctly. For instance, when I have the time zone include, I'm unable to sort it its stuck in this pattern below:

    2022-07-07 03:40:10 AM US/Central
    2022-07-07 03:33:36 AM US/Central
    2022-07-07 03:46:16 AM US/Central

  • YoDavishYoDavish Posts: 119Questions: 45Answers: 3

    Nvm I found it, I had to convert US/Central to CST or EST to work and have the 1. $.fn.dataTable.moment('YYYY-mm-dd HH:mm:ss tt zz');

    and it's now ordering correctly

Sign In or Register to comment.