mirror of
https://gitee.com/shikong-sk/gofiber-study
synced 2025-02-23 15:22:14 +08:00
自定义 time.Time 转 json 格式
This commit is contained in:
parent
9ba7ab03b0
commit
45cb7c1c66
@ -11,7 +11,7 @@ const (
|
||||
timeFormat = "2006-01-02 15:04:05"
|
||||
)
|
||||
|
||||
// MarshalJSON on JsonTime format Time field with %Y-%m-%d %H:%M:%S
|
||||
// MarshalJSON on Json Time format Time field with %Y-%m-%d %H:%M:%S
|
||||
func (t Time) MarshalJSON() ([]byte, error) {
|
||||
// 重写time转换成json之后的格式
|
||||
var tmp = fmt.Sprintf("\"%s\"", time.Time(t).Format(timeFormat))
|
||||
|
Loading…
Reference in New Issue
Block a user