r := gin.Default()
r.GET("/time", func(c *gin.Context) {
c.JSON( http.StatusOK, gin.H{
"now": time.Now(),
})
})
返回
{
"now": "2022-11-17T14:31:44.6111772+08:00"
}
就想定义 now 为 time.Time 不想定义为 string 然后 format
有 2 个疑问
- 为什么会带上毫秒、能取消掉吗?
- 有没有类似 spring boot 中的
jackson:
date-format: yyyy-MM-dd HH:mm:ss
直接全局替换