获取系统时间
year:=time.Now().Year()
month:=time.Now().Month()//time.Now().Month().String()
day:=time.Now().Day()
从数据库中存储的时间中获取年月日
month = time.Unix(answer_info.CreateTime/1000, 0).Month().String()
day = time.Unix(answer_info.CreateTime/1000, 0).Day()
year = time.Unix(answer_info.CreateTime/1000, 0).Year()
格式化时间
const base_format = "2019-01-02 15:04:05"
//获取当前时间
t := time.Now()
//2019-02-21 17:20:57.0764497 +0800 CST m=+0.018555201
fmt.Println(t)
str_time := t.Format(base_format)
//2019-02-21 17:20:57
fmt.Println(str_time)
网友评论