| 1 |
--- |
| 2 |
title: time.In |
| 3 |
description: Returns the given date/time as represented in the specified IANA time zone. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [] |
| 9 |
returnType: time.Time |
| 10 |
signatures: [time.In TIMEZONE INPUT] |
| 11 |
--- |
| 12 |
|
| 13 |
{{< new-in 0.146.0 />}} |
| 14 |
|
| 15 |
The `time.In` function returns the given date/time as represented in the specified [IANA](g) time zone. |
| 16 |
|
| 17 |
- If the time zone is an empty string or `UTC`, the time is returned in [UTC](g). |
| 18 |
- If the time zone is `Local`, the time is returned in the system's local time zone. |
| 19 |
- Otherwise, the time zone must be a valid IANA [time zone name][]. |
| 20 |
|
| 21 |
```go-html-template |
| 22 |
{{ $layout := "2006-01-02T15:04:05-07:00" }} |
| 23 |
{{ $t := time.AsTime "2025-03-31T14:45:00-00:00" }} |
| 24 |
|
| 25 |
{{ $t | time.In "America/Denver" | time.Format $layout }} → 2025-03-31T08:45:00-06:00 |
| 26 |
{{ $t | time.In "Australia/Adelaide" | time.Format $layout }} → 2025-04-01T01:15:00+10:30 |
| 27 |
{{ $t | time.In "Europe/Oslo" | time.Format $layout }} → 2025-03-31T16:45:00+02:00 |
| 28 |
``` |
| 29 |
|
| 30 |
[time zone name]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List |