You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package custom
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
|
|
type DateTime struct {
|
|
|
|
|
time.Time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MarshalJSON 实现json.Marshaler接口,自定义序列化格式
|
|
|
|
|
func (dt DateTime) MarshalJSON() ([]byte, error) {
|
|
|
|
|
formatted := `"` + dt.Format("2006-01-02 15:04:05") + `"`
|
|
|
|
|
return []byte(formatted), nil
|
|
|
|
|
}
|