time.In
Returns the given date/time as represented in the specified IANA time zone.
- Syntax
- time.In TIMEZONE INPUT
- Returns
- time.Time
Usage
The time.In function returns the given date/time as represented in the specified IANA time zone.
Arguments
TIMEZONE- (
string) The time zone. Use an empty string orUTCfor UTC,Localfor the system’s local time zone, or any valid IANA time zone name. INPUT- (
time.Time) The date/time value. To use a string representation of a date/time value, such as a custom date parameter in front matter, convert it with thetime.AsTimefunction first.
Examples
{{ $layout := "2006-01-02T15:04:05-07:00" }}
{{ $t := time "2025-03-31T14:45:00-00:00" }}
{{ $t | time.In "America/Denver" | dateFormat $layout }} → 2025-03-31T08:45:00-06:00
{{ $t | time.In "Australia/Adelaide" | dateFormat $layout }} → 2025-04-01T01:15:00+10:30
{{ $t | time.In "Europe/Oslo" | dateFormat $layout }} → 2025-03-31T16:45:00+02:00