Standard library / time

time.Time.Hour()

Return hour in the associated location, from 0 to 23. Expected stdout: '12\n'.

Formal Syntax & Structure

go syntaxgo
func (t Time) Hour() int

Return Value

int

Return hour in the associated location, from 0 to 23.

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().Hour()) }
Go Reference