Golang time.Time.Second() function example

package time

Golang time.Time.Second() function usage example. Useful in calculating second from given data programatically.

 package main

 import (
 "fmt"
 "time"
 )

 func main() {

 now := time.Now()

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

 sec := now.Second()

 fmt.Println("Second : ", sec)
 }

Sample output :

Today : Mon Aug 10 12:00:03 2015

Second : 3

Reference :

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

Advertisement