Standard library / time
time.Time.Zone()
Return the active zone abbreviation and seconds east of UTC at the instant; a location may contain many zone rules. Expected stdout: 'Plus2 7200\n'.
Formal Syntax & Structure
go syntaxgo
func (t Time) Zone() (name string, offset int)Return Value
(name string, offset int)
Return the active zone abbreviation and seconds east of UTC at the instant; a location may contain many zone rules.
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() { name, offset := fixed().In(time.FixedZone("Plus2", 7200)).Zone() fmt.Println(name, offset)}