go的html模板template格式化时间

go的html模板template格式化时间

go的html模板template格式化时间,网上一搜挺尴尬找不到想要的yyyy-MM-dd HH:mm:ss

// 代码中是这样的
//2021-09-04 14:30:29.250
fmt.Println(time.Now().Format("2006-01-02 15:04:05.000"))
//2021-09-04 14:30:29
fmt.Println(time.Now().Format("2006-01-02 15:04:05"))

那么在template应该是这样的

{{ .details.CreateTime.Format "2006-01-02 15:04:05" }}
{{ .details.CreateTime.Format "2006年01月02日 15:04:05" }}

结果:

2021-09-04 21:11:50
2021年09月04日 21:11:50
posted @ 2022-09-16 00:09  凌康  阅读(73)  评论(0编辑  收藏  举报