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