How to Convert Unix Timestamp to time.Time in Go

Convert a Unix timestamp to Go's time.Time using the time.Unix function with seconds and nanoseconds arguments.

Use the time.Unix function to convert a Unix timestamp (seconds since epoch) into a time.Time value.

import "time"

// unixTimestamp is your int64 Unix timestamp
unixTimestamp := int64(1715625600)

// Convert to time.Time
t := time.Unix(unixTimestamp, 0)

// If you have nanoseconds, pass them as the second argument
// t := time.Unix(seconds, nanoseconds)

If your timestamp includes fractional seconds (e.g., from a PAX tar header), parse the string manually or use time.Parse if the format is known, but time.Unix is the standard for integer seconds.