1

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 Answers1

0

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.

Yuri7os
  • 136
  • 1
  • 4
  • Thanks for the quick reply and clarity. All three of my above examples were added with the same (Europe/London) timezone, but they were added at different times of the year which I suspect is why they have different UTC + amounts (1 or 0). because all we need is the date (and not the time), I have advised the site administrators to simply set the time to always be 4:00AM (and leave the timezone as London), that way the API will always return the correct date and not remove an hour which it seems to do for half the year with the default 12:00AM. – David.Barry May 23 '23 at 16:54
  • Thank you for the clarification. It seems the problem is related to summertime changes rather than time zones. Unfortunately, in Kontent.ai you can only have data & time element that doesn't only store date, but also time. Since the time you select in the UI is adjusted to the target time (summertime), the date can change too. The only solution, in this case, is what you are already doing, set some time in the middle of the day so the date doesn't change for different time shifts. I've passed the feedback to our product prioritization and will update the original answer. – Yuri7os May 24 '23 at 09:08