Kontent.ai date time picker

81 Views Asked by At

I am using the Kontent.ai built in Date & Time picker for a document/file component. When we leave the time field set to 12:00AM for certain dates, the data returned by the API is subtracting an hour, this seems to be for any values that are in UTC + 1, UTC + 0 dates are fine.

File 1: - WRONG

Kontent GUI shows: May 23, 2023, 12:00 AM - (UTC +01:00)

Kontent API returns: 2023-05-22T23:00:00Z

File 2: - WRONG

Kontent GUI shows: Apr 19, 2023, 12:00 AM - (UTC +01:00)

Kontent API returns: 2023-04-18T23:00:00Z

File 2: - CORRECT

Kontent GUI shows: Feb 28, 2023, 12:00 AM - (UTC +00:00)

Kontent API returns: 2023-02-28T00:00:00Z

Is there any way to correct this inside Kontent? There doesnt look to be a way to set a default value for the time part, and I also cant see a way to force the picker to ignore the UTC and simply return the selected value.

Am I misunderstanding a fundamental of timezone handling here? Why would Kontent store a value entered by a user and then return another value via its API?

1

There are 1 best solutions below

2
On

The API returns all time values in the UTC+0 timezone, while in the Kontent.ai app UI there is a dropdown to select the timezone you want to use. The time you enter in the UI gets converted to UTC+0 before it is returned from the API.

In the UI you should see a dropdown with a timezone next to the date-time input like so. enter image description here

By default your current timezone is preselected. If you want to define time in the UTC+0 timezone, you can just select it in the dropdown next to the input.

The goal of the design is to simplify date-time definition by allowing it to be defined in any timezone (and save it so that edits can also be made in the selected timezone). However, on the API side, it is easier to work with times defined in one timezone so that developers don't need to convert all time values themselves.

edit: After understanding the problem a bit more, it seems to problem is related to the summertime shift rather than a different time zone and the fact that Kontent.ai always store date and time rather than just a date. The only workaround is, as David mentioned, to set the time explicitly (by default the time is 12 AM which leads to a date change in a summertime shift) to some time during the day so that the summertime shift doesn't cause a date change.