Go time: measure and display clocks and durations
Answer: The time package measures and displays time. Its calendrical calculations assume a Gregorian calendar in all cases. Add adds the same duration to both the wall clock and monotonic clock readings. Sleep pauses the current goroutine.
Examples
package main
import "time"
func main() {
now := time.Now()
later := now.Add(2 * time.Second)
time.Sleep(10 * time.Millisecond)
_ = later.Sub(now)
}
Notes
The zero Time value does not format as a normal date. On some systems the clock can stop if the computer goes to sleep, and Sub may not accurately reflect the actual time that passed. Duration values such as Second are used with Add and Sleep.
Reference list
Thetime package measures and displays time.Calendricalcalculations assume a Gregorian calendar.Addapplies the duration to both wall clock and monotonic readings.
See also
Claims
- id: C1 claim: The time package measures and displays time. source: S1 evidence: "Package time provides functionality for measuring and displaying time"
- id: C2 claim: Calendrical calculations assume a Gregorian calendar. source: S2 evidence: "The calendrical calculations always assume a Gregorian calendar"
- id: C3 claim: Add applies the duration to both wall clock and monotonic readings. source: S2 evidence: "t.Add adds the same duration to // both the wall clock and monotonic clock readings"
Sources
- [S1] time package. Go docs. https://pkg.go.dev/time . License: BSD-3-Clause. Accessed 2026-11-18.
- [S2] time.go. Go source. https://raw.githubusercontent.com/golang/go/master/src/time/time.go . License: BSD-3-Clause. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go docs, time package; Go source, time.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Go docs, time package; Go source, time.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go time: measure and display clocks and durations." iinventedlight Library, iil:note:rmnpjpkk, version of 2026-11-18. https://iinventedlight.com/library/notes/go-time/. License: CC-BY-4.0.
@misc{iil_note_rmnpjpkk,
author = {{iinventedlight}},
title = {{Go time: measure and display clocks and durations}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/go-time/},
note = {Permanent ID iil:note:rmnpjpkk. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-time.table.json (table; CC-BY-4.0)
- go-time.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-time.md.