Standard library / time

time.Time.In()

Return the same instant displayed in loc; nil loc panics. The monotonic reading is removed. Expected stdout: '2024-02-29T14:34:56+02:00\n'.

Formal Syntax & Structure

go syntaxgo
func (t Time) In(loc *Location) Time

Parameters & Attributes

NameTypeDescription
loc*LocationLocation providing calendar and zone rules.

Return Value

Time

Return the same instant displayed in loc; nil loc panics.

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func fixed() time.Time { return time.Date(2024, 2, 29, 12, 34, 56, 123000000, time.UTC) }func main()            { fmt.Println(fixed().In(time.FixedZone("Plus2", 7200)).Format(time.RFC3339)) }
Go Reference