Standard library / time
time.Unix()
Construct an instant from seconds and nanoseconds since the Unix epoch; nsec is normalized. Result uses Local; convert to UTC for stable display. Expected stdout: '1970-01-01T00:00:01.5Z\n'.
Formal Syntax & Structure
go syntaxgo
func Unix(sec int64, nsec int64) TimeParameters & Attributes
| Name | Type | Description |
|---|---|---|
| sec | int64 | Seconds since Unix epoch. |
| nsec | int64 | Nanosecond component. |
Return Value
Time
Construct an instant from seconds and nanoseconds since the Unix epoch; nsec is normalized.
Working Example
Example Snippetgo
package main
import ( "fmt" "time")
func main() { fmt.Println(time.Unix(0, 1500000000).UTC().Format(time.RFC3339Nano)) }