1.日期->时间戳
timestamp := time.now().Unix() //转化为时间戳 类型是int64
2.时间戳->日期
timeNow := time.Unix(time.Now().Unix(),0)
3.日期->字符串
timeLayout := "2006-01-02 15:04:05" //转化所需模板 timeString := time.now().Format(layout)
4.字符串->日期
timeString := "2019-07-29 00:00:00" layout := "2006-01-02 15:04:05" loc, _ := time.LoadLocation("Local") tmp, _ := time.ParseInLocation(layout, timeString, loc)标签:00,layout,Unix,时间,timeString,time,go,格式 From: https://www.cnblogs.com/beatle-go/p/17469604.html