Event datetime UTC versus local timezone in NetlifyCMS and Hugo

I have Events in my Hugo site. NetlifyCMS shows the Event Date (.date) field correctly for my time zone. The date gets stored in the Event’s frontmatter as UTC, not the local time the NetlifyCMS displays. When the site is built, UTC is used. Example: when the user selects Feb 1, 9PM in NetlifyCMS it shows on the deployed site as February 2nd, 4AM. I need to get the datetime the user sees to match the datetime deployed on the live site.

I have tried timezones in Hugo but that didn’t work. I tried adding timeZone: America/Boise to config.yaml but nothing changed.

Per another thread, in the root directory I have netlify.toml with the following contents:
[build.environment]
TZ = “America/Boise”
[context.production.environment]
TZ = “America/Boise”
I tried clearing the cache and redeploying but this didn’t help.

https://musing-blackwell-c5f5bf.netlify.app

I will use UTC in the CMS and the live site and just not show the time zone. The preview window shows my local time so it is still a little wonky but trying to add TZ into the netlify.toml file broke identity (even after disabling git-gateway, enabling it, reissuing the API key, clearing cache and redeploying).

1 Like

Hi there! Glad to hear you found a solution by using UTC in the CMS. Should you wish to dig into CMS obstacles in the future, here are some additional resources :slight_smile:

netlifycms.org - the site houses our extensive documentation that likely contains helpful information to get you back on track.

netlify cms slack - join our friendly slack channel and chat with other cms pros to get the help you need.

GitHub Issues - think you’ve found a bug, or would like to make a feature request? Make your voice heard here. Netlify CMS is open source - PRs and other contributions are also welcome!

Stack Overflow Check StackOverflow for questions tagged “Netlify CMS” if you don’t get an answer in the Slack or the GH issues. StackOverflow reaches a worldwide audience of knowledgeable people.

Again, glad you found a workaround for now!!