Before, After, and Equal compare two deterministic time values.

Compare Times

compare_times.go
package main

import (
	"fmt"
	"time"
)

func main() {
	var offsetHours = 
	deadline := time.Date(2026, time.May, 28, 12, 0, 0, 0, time.UTC)
	check := deadline.Add(time.Duration(offsetHours) * time.Hour)
	isBefore := check.Before(deadline)
	isAfter := check.After(deadline)

	fmt.Println("offsetHours=", offsetHours)
	fmt.Println("check=", check.Format("15:04"))
	fmt.Println("before=", isBefore)
	fmt.Println("after=", isAfter)
}
package main

import (
	"fmt"
	"time"
)

func main() {
	var offsetHours = 
	deadline := time.Date(2026, time.May, 28, 12, 0, 0, 0, time.UTC)
	check := deadline.Add(time.Duration(offsetHours) * time.Hour)
	isBefore := check.Before(deadline)
	isAfter := check.After(deadline)

	fmt.Println("offsetHours=", offsetHours)
	fmt.Println("check=", check.Format("15:04"))
	fmt.Println("before=", isBefore)
	fmt.Println("after=", isAfter)
}
package main

import (
	"fmt"
	"time"
)

func main() {
	var offsetHours = 
	deadline := time.Date(2026, time.May, 28, 12, 0, 0, 0, time.UTC)
	check := deadline.Add(time.Duration(offsetHours) * time.Hour)
	isBefore := check.Before(deadline)
	isAfter := check.After(deadline)

	fmt.Println("offsetHours=", offsetHours)
	fmt.Println("check=", check.Format("15:04"))
	fmt.Println("before=", isBefore)
	fmt.Println("after=", isAfter)
}
compare time Comparing times answers ordering questions without relying on the current clock.