Skip to content

Instantly share code, notes, and snippets.

@1000copy
Created April 12, 2014 10:55
Show Gist options
  • Select an option

  • Save 1000copy/10529863 to your computer and use it in GitHub Desktop.

Select an option

Save 1000copy/10529863 to your computer and use it in GitHub Desktop.
import (
"time"
)
// 时间格式化字符串(奇葩的设置)
const TimeFormat = "2006-01-02 15:04:05"
const TimeFormat1 = "2006-01-02"
func TestXYZ(t *testing.T) {
r1,_:=time.Parse(TimeFormat1,"2014-04-11")
r2,_:=time.Parse(TimeFormat1,"2014-04-12")\
// 取得当年日期和时间
r4 :=time.Now()
// 判断时间的前后关系
r := r1.Before(r2)
t.Error(r)
t.Error(r4)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment