Go: Current time

Use the time.Now function and the time.Unix and time.UnixNano methods to get a timestamp.

now := time.Now()      // current local time
sec := now.Unix()      // number of seconds since January 1, 1970 UTC
nsec := now.UnixNano() // number of nanoseconds since January 1, 1970 UTC

fmt.Println(now)
fmt.Println(sec)
fmt.Println(nsec)
2009-11-10 23:00:00 +0000 UTC m=+0.000000000
1257894000
1257894000000000000

Comments