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
请发表评论