import “time”
官方文档
func main() {
fmt.Println(time.Now())
fmt.Println(time.Parse("2006.01.02", "2012.02.11"))
date := time.Now()
fmt.Println(date.Equal(time.Now()))
time.Sleep(200)
temp := time.Now()
if temp.Before(date) {
fmt.Println("Before")
} else {
fmt.Println("如果t代表的时间点在u之前,返回真;否则返回假。")
}
if temp.After(date) {
fmt.Println("Before")
} else {
fmt.Println("如果t代表的时间点在u之前,返回真;否则返回假。")
}
fmt.Println(time.Date)
fmt.Println(temp.Clock())
fmt.Println(temp.Year())
fmt.Println(temp.Month())
fmt.Println(temp.Day())
fmt.Println(temp.YearDay())
fmt.Println(temp.Day())
fmt.Println(temp.Weekday())
fmt.Println(temp.Hour())
fmt.Println(temp.Minute())
fmt.Println(temp.Second())
fmt.Println(temp.Nanosecond())
fmt.Println(temp.Date())
fmt.Println(temp.AddDate(1,0,0))
fmt.Println(temp.Sub(date))
fmt.Println(temp.Sub(date).Seconds())
layout := "2006-01-02 03:04:05"
fmt.Println(date)
fmt.Println(date.Format(layout))
fmt.Println(date.String())
}