Standard library / time
time.Time.Equal()
Compare instants rather than structural identity; different locations can describe the same instant. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func (t Time) Equal(u Time) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| u | Time | Other instant for comparison or subtraction. |
Return Value
bool
Compare instants rather than structural identity; different locations can describe the same instant.
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() { t := fixed(); u := t.In(time.FixedZone("Plus2", 7200)); fmt.Println(t.Equal(u), t == u) }