TimeZone editing in the DatePicker

TimeZone editing in the DatePicker

AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0

Hello Allan, I really liked the DatePicker you have created but on occation my users also need the ability to specify a specific TimeZone.

Since the DatePicker was on Github I forked it and added the functionality and created a PR. I tried sticking with your coding style.

https://github.com/DataTables/DateTime/pull/2/commits/228bbec927a0bab0672bf26a0a7b25ea1922da2d

Thanks

Replies

  • AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0

    On the page: https://editor.datatables.net/examples/dates/formatting-client.html

    The javascript on line 18 should be updated from

         var m = window.moment( d, from, locale, true );
    

    to

        var m = from.indexOf('Z') > -1
            ? moment.parseZone(d, from)
            : window.moment(d, from, locale, true);
    

    This allows a user to specify that they want to see the TimeZone in the date and then DataTables.net will render the date showing the original TimeZone in the date field.

  • AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0

    By way of explaination. These changes were needed to support the DateTimeOffset field in SQL Server. This field is unique because is stores the Date, Time and TimeZone as distinct pieces. This means you can record not only the date and time but also the specific timezone for a given event.

    https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetimeoffset-transact-sql

This discussion has been closed.