golang 时间函数 包time
-
time.Now() //获取当前时间
// 2019-08-19 04:18:33.9420492 +0000 UTC m=+0.227973101
-
time.Parse(layout,value string) (Time,error) // 解析一个格式化时间字符串并返回代表的时间,layout 定义参考时间
// fmt.Println(time.Parse(“2006-01-02 15:04:05”, “2019-12-03 22:01:02”)) 2019-12-03 22:01:02 +0000 UTC
-
time.ParseInLocation(layout, value string, loc *Location) (Time, error) //使用模板在对应时区转化为time.time类型 ,layout定义参考时间,value字符串,Location 设置loc
// time.ParselnLocation(“2019-01-02 15:04:05”,“2019-12-03 22:02:02”,time.Location) 2019-12-03 22:02:02 +0000 UTC
-
time.Unix(sec int64,nsec int64) Time //时间戳转换本地时间 sec 秒 nsec 纳秒
// fmt.Println(time.Unix(1487780010, 1)) 2017-02-22 16:13:30.000000001 +0000 UTC
-
t.Location() *Location //返回某时间的地点和时区信息
// t := time.Now() fmt.Println(t.Location()) //Local
-
t.U