go格式化时间必须使用6-1-2-3-4-5这个时间点

时间戳

1
fmt.Println(time.Now().Unix())

格式化

1
fmt.Println(time.Now().Format("2006-01-02 15:04:05"))

时间戳格式化

1
time.Unix(1389058332, 0).Format("2006-01-02 15:04:05")

时间解析

1
2
3
4
the_time, err := time.Parse("2006-01-02 15:04:05", "2014-01-08 09:04:41")
if err == nil {
unix_time := the_time.Unix()
}

其他操作

1
2
the_time := time.Date(2014, 1, 7, 5, 50, 4, 0, time.Local)
unix_time := the_time.Unix()