Golang time.Time.Hour() function example

package time

Golang time.Time.Hour() function usage example.

  package main

  import (
 "fmt"
 "time"
  )

  func main() {

 now := time.Now()

 fmt.Println("Today : ", now.Format(time.ANSIC))

 hour := now.Hour()

 fmt.Println("Hour : ", hour)
  }

Sample output :

Today : Thu Aug 6 10:38:47 2015

Hour : 10

Reference :

http://golang.org/pkg/time/#Time.Hour

Advertisement