求2个字符串对比

hellsam · · 1119 次点击
https://github.com/Juntaran/Go_In_Action/tree/master/Demo/TimeChina 可以用这段转成时间戳再对比
#3
更多评论
```go func CompareTime(t1, t2 string) bool { FORMAT := "2006-01-02 15:04:05" T1, err := time.Parse(FORMAT, t1) if err != nil { panic(err) } T2, err := time.Parse(FORMAT, t2) if err != nil { panic(err) } if T1.Sub(T2).Hours() == 24 { return true } return false } ```
#1
<a href="/user/hellsam" title="@hellsam">@hellsam</a> 根据你的需要来,有可能需要改成 `xx == 24 || xx == -24`
#2