Convert Unix timestamps in Go with live parser and time package snippets. Unix(), UTC, and locations.
Smart Universal Parser
// Paste Unix seconds/ms, ISO 8601, RFC 2822, or a human date.
Developer Snippets
// Copy-ready code — current timestamp injected automatically.
Go’s standard time package covers everything you need for epoch conversions without third-party libraries: reading the clock, converting seconds or milliseconds to a time.Time, formatting with Go’s reference-date layouts, and applying IANA time zones. The live parser above checks any timestamp, and the snippet panel generates a runnable Go program with the current value filled in. Conversions happen in your browser only; no input leaves the tab.
Unix(), UnixMilli(), UnixNano()now := time.Now()
secs := now.Unix() // int64 seconds, e.g. 1715429912
ms := now.UnixMilli() // int64 milliseconds (Go 1.17+)
ns := now.UnixNano() // int64 nanosecondsUnixMilli and UnixMicro were added in Go 1.17. Before that, people wrote UnixNano() / 1e6, which you will still see in older code.
time.Time with time.Unixtime.Unix(sec, nsec) builds a time.Time from seconds plus nanoseconds. The result carries the local location of the machine, so call .UTC() for predictable output in logs and APIs. For milliseconds, use time.UnixMilli(ms).
package main
import (
"fmt"
"time"
)
func main() {
t := time.Unix(1715429912, 0).UTC()
fmt.Println(t.Format(time.RFC3339)) // 2024-05-11T12:18:32Z
fmt.Println(t.Format("2006-01-02 15:04:05")) // 2024-05-11 12:18:32
loc, err := time.LoadLocation("America/New_York")
if err != nil {
panic(err)
}
fmt.Println(t.In(loc).Format("Mon Jan 2 15:04:05 MST 2006"))
// Sat May 11 08:18:32 EDT 2024
fmt.Println(time.UnixMilli(1715429912000).UTC()) // 2024-05-11 12:18:32 +0000 UTC
}This output confirms 1715429912 is Saturday, May 11, 2024 at 12:18:32 UTC, and 08:18:32 EDT in New York.
2006-01-02 15:04:05Go does not use %Y-%m-%d tokens. A layout is the reference moment Mon Jan 2 15:04:05 MST 2006 written the way you want your output to look. Each component has a fixed value: year 2006, month 01 or Jan, day 02, hour 15 (or 03 for 12-hour), minute 04, second 05, zone MST or -0700. A handy mnemonic is 1-2-3-4-5-6-7: month 1, day 2, hour 3 (15), minute 4, second 5, year 6, zone −7.
If you write a real date as the layout, such as "2024-05-11", Go reads those digits as layout tokens and prints garbage. Prefer the predefined constants time.RFC3339, time.DateTime ("2006-01-02 15:04:05", Go 1.20+), and time.DateOnly.
p, err := time.Parse(time.RFC3339, "2024-05-11T12:18:32Z")
if err != nil {
return err
}
fmt.Println(p.Unix()) // 1715429912time.Parse treats strings without zone information as UTC. Use time.ParseInLocation when the input is a local wall-clock time.
By default, encoding/json marshals a time.Time as an RFC 3339 string with nanosecond precision, such as "2024-05-11T12:18:32Z". If your API contract uses numeric epoch seconds instead, declare the field as int64 and convert with t.Unix() and time.Unix(), or write a small wrapper type with custom MarshalJSON and UnmarshalJSON methods. Whichever you choose, document the unit in the field name (created_at_unix, expires_ms) so clients in other languages don’t guess wrong. Most SQL drivers scan timestamp columns straight into time.Time. Call .UTC() before writing so the stored value never depends on the server’s location.
scratch have no zoneinfo, so LoadLocation fails. Add import _ "time/tzdata" to embed the database in the binary, or install tzdata in the image.==. time.Time values with different locations or monotonic readings can be unequal even at the same instant. Use t1.Equal(t2).time.UnixMilli, not time.Unix, for 13-digit values. See seconds vs milliseconds.t2.Sub(t1) returns a time.Duration. For a visual check of any interval, the timestamp diff calculator gives the same answer instantly.Use time.Now().Unix() for seconds or time.Now().UnixMilli() for milliseconds. Both return int64.
Call time.Unix(sec, 0), and add .UTC() for UTC output. For milliseconds use time.UnixMilli(ms).
Go layouts are written using the reference time Mon Jan 2 15:04:05 MST 2006. You describe the output format by writing that moment in the shape you want.
The image has no timezone database. Add import _ "time/tzdata" to embed it, or install the tzdata package in the image.
No. Use Equal, Before, and After. The == operator also compares location and monotonic clock data.
Yes. All parsing and snippet generation happens in your browser; nothing is uploaded.