go语言时间比较
local, _ := time.LoadLocation("Local") starttime, _ := time.ParseInLocation("2006-01-02 15:04:05", "2017-10-23 15:01:01", local) endtime, _ := time.ParseInLocation("2006-01-02 15:04:05", "2017-10-24 15:05:01", local) now := time.Now() fmt.Println(now) fmt.Println(endtime, endtime.After(now)) fmt.Println(starttime, starttime.Before(now))
输出
2017-11-23 00:55:31.184488 +0800 CST 2017-10-24 15:05:01 +0800 CST false 2017-10-23 15:01:01 +0800 CST true
- 上一篇 »go语言基础之结构体比较和赋值
- 下一篇 »Go语言操作mongoDB