Standard library / time

time.Time.IsZero()

Report whether the time is the zero instant, January 1 of year 1 at midnight UTC. Expected stdout: 'true false\n'.

Formal Syntax & Structure

go syntaxgo
func (t Time) IsZero() bool

Return Value

bool

Report whether the time is the zero instant, January 1 of year 1 at midnight UTC.

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func fixed() time.Time { return time.Date(2024, 2, 29, 12, 34, 56, 123000000, time.UTC) }func main()            { fmt.Println((time.Time{}).IsZero(), fixed().IsZero()) }
Go Reference