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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM