timestamp to time golang code example
Example 1: timestamp to time golang
timeUnix 1257894000
time.Time: 2009-11-10 23:00:00 +0000 UTC
Example 2: timestamp to time golang
package main
import (
"fmt"
"time"
)
func main() {
tNow := time.Now()
//time.Time to Unix Timestamp
tUnix := tNow.Unix()
fmt.Printf("timeUnix %d\n", tUnix)
//Unix Timestamp to time.Time
timeT := time.Unix(tUnix, 0)
fmt.Printf("time.Time: %s\n", timeT)
}