golang比较时间大小问题,急求,有礼赠送

wnoum123 · · 2830 次点击
给你个参考: ```go func main() { layout := "2006-01-02 15-04-05" str1 := "2016-05-10 09:30:29" str2 := "2016-05-20 08:50:12" loc, _ := time.LoadLocation("PRC") time1, _ := time.ParseInLocation(layout, str1, loc) //不是UTC标准时间,或格式不带时区,则要给定时区 time2, _ := time.ParseInLocation(layout, str2, loc) fmt.Println(time1.After(time2)) //output: //false } ```
#2
更多评论
很简单,先初始化,再比较。具体可以看看我前几天才发的: http://blog.csdn.net/qq_26981997/article/details/53454606
#1
Go中的字符串操作是有内置重载操作符的 ```go package main import ( "fmt" ) func main() { a := "2016-05-10 09:30:29" b := "2016-05-20 08:50:12" fmt.Println(a < b) } ```
#3