时间的类型 date time timestamp
data 2019-3-20 [15:04:05]
time 2019-3-20 +0.23123 CST
timestamp 1553069264
t := time.Now() // 获取当前时间
layout = "2006-01-02 [15:04:05]" // date格式12150405
loc := time.LoadLocation("Location") //获取当前时区
(1) time =>
t.Format(layout) //time => date
t.Unix() // time => timestamp
(2)timestamp => time
time.Unix(timestamp,0) //
(3)date => time
time.ParseInLocation(layout,date,loc)
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)