Standard library / time
time.Time.Before()
Report whether t is strictly earlier than u; equality returns false. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func (t Time) Before(u Time) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| u | Time | Other instant for comparison or subtraction. |
Return Value
bool
Report whether t is strictly earlier than u; equality returns false.
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(); fmt.Println(t.Before(t.Add(time.Second)), t.Before(t)) }