New Timezone feature in v0.87

Did I understand it correctly that the new timezone feature in v0.87 was only meant for display and not auto-adjusting the time itself?

I’ve been testing around and the only way for auto-adjust to work is if I use .UTC.Format or .Local.Format in the theme itself which also overrides all languages to displaying that timezone (UTC or system Local).

What I’m trying to achieve is the post will display its “Local” time based on the language of the post.

  1. In my site config.toml I have this set per language: timeZone = "" Asia/Manila for en-ph; Asia/Tokyo for ja; Asia/Seoul for ko
  2. In I have this: date = "2021-08-15T09:40:35" (without the timezone, otherwise it will be fixed to that)
  3. I removed the .UTC / .Local in the theme files, so it’s just .Date.Format now.

However, when I switch to a different language, the only thing that changes is the TimeZone abbreviation, it doesn’t adjust the time to the timezone that was set in config.toml. So, 2021-08-15T09:40:35 appears as:

  • 2021-08-15 09:40:35 PST (n.b. Philippine Standard Time)
  • 2021-08-15 09:40:35 JST – it should be 10:40:35 JST
  • 2021-08-15 09:40:35 KST – it should be 10:40:35 KST

If the new timeZone feature was meant for display only, is there a way to add, in this case, +1 automatically? This way I don’t have to double-check the date value in each post if it was adjusted accordingly?

Thank you!

Does this help (see ‘using locations’)?

Unfortunately, nope, those are the settings I already have. :slight_smile:

My current setup is to manually adjust the time in each without the hardcoded timezone so the language timezone setting will show the timezone abbreviation. If I don’t change the time in each for each language, it will show as-is without the timezone adjustment (say +1 hour) while displaying the timezone abbreviation. (see example in original post)

See for example: YOOki Chronicles or Snoworld

It looks like this isn’t possible with only formatting, even in straight Go. In Go it looks like to change timezone, other than for Local and UTC, you need time.GetLocation(). I guess this would need to be a feature request and/or PR to Hugo. Based on

1 Like

No, it’s not only meant for display.

When I, the Norwegian, say:

publishDate = "2021-08-15"

That is at midnight in time zone “Europe/Oslo” with offset +2, which is when I want my article published. That has been one very common issue with Hugo where the build server (e.g. Netlify, UTC) is many hours ahead/behind the author’s location.

By setting a time zone in config you’re telling Hugo that all dates without any time zone/offset info is in this time zone.

So, not only for display, but also isn’t meant for what @techmagus is trying to do (if I understand the magus’ goal correctly), which is to display a time as the time in a particular timezone, depending on the language of the post. (That is to translate a post in EST to say JST or KST depending on language). Is that correct?

If there is a way to do that, I’d be interested so that I could have my Netlify posts in my timezone instead of Netlify’s (even when the original post already has a timezone), since .Local gives Netlify’s time and UTC isnt’ what I want.

1 Like

That is correct. To be clear, when I write:

date = "2021-08-15T09:40:35"

The time is meant to be my wall clock. If Hugo somehow magically adjusted that by 2 hours, that would not be the correct time.

There may be a way to do what he wants, but I haven’t thought too hard about that.

1 Like

Got it, thank you for the answers! Much appreciated :slight_smile:


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.