Changing timezone of timestamp to an arbitrary timezone

As I understand it, currently a timestamp can be displayed with one of three timezones:

  • The original timezone of timestamp in config file or front matter (for this I include the 0.87.0 timezone)
  • Date.Local
  • Date.UTC

If I want posts (some with UTC timestamps, some with EST) displayed in EST, is there currently a way to do that for a Netlify site (which IIRC uses PST as .Local)?

EDIT: If I’m not being clear, I can create an example.

content/post/post-1.md

+++
title = "Post 1"
date = 2021-08-19T10:00:00-05:00  # 2021-08-19T11:00:00 in America/New_York
draft = false
+++

content/post/post-2.md

+++
title = "Post 2"
date = 2021-08-19T09:00:00-00:00  # 2021-08-19T05:00:00-00:00 in America/New_York
draft = false
+++

layouts/_default/single.html

{{ define "main" }}
  <h1>{{ .Title }}</h1>
  <p>{{ .Date.Local }}</p>
  {{ .Content }}
{{ end }}

CLI

TZ="America/New_York" hugo

See:
https://answers.netlify.com/t/can-i-set-a-custom-timezone-in-the-build-environment/1915

1 Like

Thank you! I would never have thought to check for that option on Netlify, even though I use environment variables for other things with them.

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