Datetime picker with Dayjs
Datetime picker with Dayjs
Link to test case: https://live.datatables.net/haqesiyu/25/
Note: Not able to get datetime working. Showing the configuration as example
Debugger code (debug.datatables.net): N/A
Error messages shown: No error messages
Description of problem:
Versions: Datetime 1.5.5, Editor 2.4.2, Dayjs 1.11.13 (and its plugins) along with jQuery 3.7.1
There is a date time column, which requires to be edited by users on UI. This date time column is in format YYYY-MM-DDTHH:mm:ssZ
or (YYYY-MM-DD[T]HH:mm:ssZ
for dayjs). Everything looks good when loaded, however, when datetime column inline editor opens, calendar is shown. However, the calendar does not select given date automatically. For example, if the data from server is "2020-06-01T00:00:00-04:00", render formats it "06/01/2020" and when I click on that cell, calendar widget is open and no date is select in the widget. Also the input is empty.
If I tweak data by striping away THH:mm:ssZ
(i.e., 2020-06-01
) then everything works as expected. Does ISO8061 format works with the datetime picker widget?
Answers
Hi,
The date picker currently doesn't handle timezone information. That is something that I need to make some time to upgrade it for. Sorry it doesn't handle that better yet - it is something that is on the slate, but I'm not yet sure when it will be.
Allan
Thanks @Allan for quick response.
Does this imply it does have workaround? Also, to clarify, datetime only supports
YYYY-MM-DD
format?There isn't really a workaround I'm afraid. Don't give it the timezone - treat everything as if it were UTC (without the Z).
Without Moment, Luxon or DayJS, then yes. With those libraries, you can use the
format
option to tell it what format it use - e.g. this example with Moment.Allan
It might also be worth taking a look at the Editor date / time examples, specifically the client-side and server-side "Formatted dates" examples.
Personally I prefer sending ISO8601 over the wire, and doing the formatting client-side, but it is possible to handle already formatted dates.
Allan