time.Unix
Get the current Unix timestamp in Go
Go uses `time.Now()` for an instant and `time.Unix(sec, nsec)` to build one from epoch parts. Unlike many languages, Go encourages nanoseconds via `UnixNano()`.
Format with `time.RFC3339` (ISO 8601) or any custom layout from the reference time "Mon Jan 2 15:04:05 MST 2006".
Current Unix timestamp (seconds)
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now().Unix()
fmt.Println(now) // 1,754,136,000
} Convert epoch seconds → ISO 8601 (UTC)
t := time.Unix(1754136000, 0).UTC()
fmt.Println(t.Format(time.RFC3339)) // 2025-08-02T12:00:00Z Real-world use cases for Go
- Adding a timestamp to JSON responses from a Go API using time.Now().Unix().
- Comparing a stored token expiry against time.Now().Unix() without importing a date library.
- Logging request start times as epoch seconds and measuring latency with time.Since().
| Unix timestamp (seconds) | ISO 8601 (UTC) |
|---|---|
| 0 | 1970-01-01T00:00:00.000Z |
| 946,684,800 | 2000-01-01T00:00:00.000Z |
| 1,754,136,000 | 2025-08-02T12:00:00.000Z |
| 2,147,483,647 | 2038-01-19T03:14:07.000Z |
| 2,524,608,000 | 2050-01-01T00:00:00.000Z |
These are the same fixed timestamps used in the Go examples above — every conversion returns one of these values.
Frequently asked questions
How do I get the current Unix timestamp in Go?
time.Now().Unix() returns the current epoch in seconds, and .UnixMilli() / .UnixNano() give you the millisecond and nanosecond variants. All are int64 values, so no overflow worries.
How do I convert an epoch timestamp to a date in Go?
time.Unix(1754136000, 0) builds a time.Time from epoch seconds. Call .UTC() and then t.Format(time.RFC3339) to print the ISO 8601 string, or t.In(loc) to render it in any IANA timezone.
Why does Go use 1_506_330_201 as the reference layout time?
Go formats times by example rather than tokens. The reference time "Mon Jan 2 15:04:05 MST 2006" spells out 01/02/03:04:05/06 so each number uniquely identifies a component in any layout string.
Epoch to human date in Go
Try it live — convert any timestamp in Go-friendly format.
Seconds or milliseconds — the unit is auto-detected. Example: 1735689600
UTC ISO 8601
–
Local — auto
–
RFC 2822 / GMT
–
Seconds value
–
Relative time
–
Other programming languages
Copy-paste epoch conversion snippets in your favorite stack
More timestamp guides
Example values used above: epoch seconds = 1,754,136,000 · ISO 8601 = 2025-08-02T12:00:00.000Z. Curious how the numbers work? See the Unix epoch time FAQ, or view the current epoch time in any timezone.