timestamper.online
Back to Guides

How to Handle Unix Timestamps in Go (Golang)

Convert Unix time in Go using the standard `time` package.

1. Get Current Timestamp
go (golang)
package main
import ("fmt"; "time")

func main() {
    // Current timestamp
    now := time.Now().Unix()
    fmt.Println(now)
}
2. Convert Date to Timestamp
go (golang)
// Date to timestamp
t, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")
ts := t.Unix()
3. Convert Timestamp to Readable Date
go (golang)
// Timestamp to date
t := time.Unix(1704067200, 0)
fmt.Println(t.UTC())

Need to convert a specific timestamp right now?

Use Online Converter