Table of Contents

time package

What is it?

`time` is Go’s standard library package for working with:

What is it used for?

Core types

Core functions (most common)

Example: current time

now := time.Now()
fmt.Println(now)

Example: measure elapsed time

start := time.Now()
// do work...
elapsed := time.Since(start)
fmt.Println("elapsed:", elapsed)

Example: sleep

time.Sleep(500 * time.Millisecond)

Example: parse + format (RFC3339)

t, err := time.Parse(time.RFC3339, "2026-01-09T10:30:00+07:00")
if err != nil { return err }
 
s := t.Format(time.RFC3339)
fmt.Println(s)

Example: custom layout (Go layout rule)

Go uses a reference time to define layouts:

Child pages:

* Go time layout reference `