Product Updates

DatoCMS changelog for new features and general improvements
Content Management APIContent Delivery API
Improved timezone management
May 17th, 2022

Today we're switching to a better management of timezones in datetime values stored in your projects!

Current behaviour

DateTime fields in your records do not carry timezone information.

If you use the Content Management API to create/update a record, and you provide an ISO8601 datetime complete with timezone to a DateTime field, the timezone part is completely ignored by the system. Just the date + time information will be stored in the field value, and the project timezone will be automatically applied to it when the API outputs the value.

const record = await client.items.update('324342', {
dateTimeField: '2000-01-01T09:30+10:00',
});
console.log(record.dateTimeField);

In this example, if the timezone setting in your project is Europe/Rome, the returned datetime won't be 2000-01-01T09:30+10:00, but 2000-01-01T09:30+01:00 .

Also, if you change the timezone setting in the future to be ie. Pacific Time, the same date will immediately become 2000-01-01T09:30-08:00, and every other date stored in your records' fields will change similarly. This basically has the effect of moving dates in time.

Improved behavior

DateTime fields in your records DO carry timezone information with them.

The only effect of the global timezone setting is to return via API every datetime value coherently converted in the same timezone.

Following the same example used above, if the timezone setting in your project is Europe/Rome, and you update a datetime field value passing 2000-01-01T09:30+11:00, the datetime returned by the API will be 1999-12-31T23:30+01:00 — that is, same point-in-time, but expressed in the project timezone.

If you change the timezone setting in the future to be ie. Pacific Time, the same date will immediately be presented via API in the new timezone (1999-12-31T14:30-08:00), but the point-in-time will be kept intact.

Who is affected by this change?

Every brand new DatoCMS project created starting from today will be under the improved behavior. If you want to switch your existing project to the new behavior, you can manually do so in the Environment Settings:

PS: Be aware that the change cannot be undone, so be sure to test the effects in a sandbox environment before applying the change to your primary environment!