- time
- Now
- Unix
Time example
The Now function of the time package will return a representation of the current time.
When printed it will show well formatted datetime string, but we can also use the Unix and UnixNano functions
to the the time elapsed since the epoch in seconds and nanoseconds respectively.
examples/time/time.go
package main import ( "fmt" "time" ) func main() { t := time.Now() fmt.Printf("%T\n", t) fmt.Println(t) fmt.Println(t.Unix()) fmt.Println(t.UnixNano()) }
time.Time 2020-04-24 21:54:38.111505742 +0300 IDT m=+0.000032815 1587754478 1587754478111505742