Shell
·
發表于 4年以前
·
閱讀量:2598
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now()
timeDur := time.Duration(10)*time.Second + time.Duration(1)*time.Minute
nowAddTime := now.Add(timeDur)
//時間比較
//時間之前比較
fmt.Println(nowAddTime.After(now)) //true
//時間之后比較
fmt.Println(nowAddTime.Before(now)) //false
//時間相等比較
fmt.Println(now.Equal(now)) //true
}