For Developers

Unix Timestamp in Go

How to get the current timestamp, convert it to a date, and convert a date back to a timestamp in Go — plus the specific mistake that trips up Go code more than any other.

time.Now().Unix()
time.Unix(1750000000, 0)
time.Date(2025,6,15,12,0,0,0,time.UTC).Unix()

The Go-specific pitfall

Go's time.Time is timezone-aware by design — every Time value carries a *Location — so the naive/aware bug class that hits Python and C# mostly can't happen here. The more common Go-specific mistake is forgetting that time.Unix()'s second argument is nanoseconds, not milliseconds, and passing a millisecond value straight into it without conversion.

Have a timestamp right now?

Paste it into the Timestamp ⇄ Date Converter to check it instantly, in any timezone, without writing any code. Working across several languages on the same project? The full Epoch Time in Programming Languages guide has all of them side by side for quick comparison.

Related

Related tools & reading