[Go] Convert a Unix timestamp to a time.Time

Created on November 30, 2026

Use time.Unix with the number of seconds since the Unix epoch and a nanosecond offset. Pass 0 for the second argument if the timestamp has only whole seconds.

package main

import (
    "fmt"
    "time"
)

func main() {
    t := time.Unix(1620033031, 0)
    fmt.Println(t.Format("2006-01-02 15:04:05"))
}
Go