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) Time

Parameters & Attributes

NameTypeDescription
secint64Seconds since Unix epoch.
nsecint64Nanosecond 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)) }
Go Reference