Go的time.Time的增强类型
dt := datetime.New()
fmt.Println(dt) // yyyy-MM-dd HH:mm:ss
//get
dtStr := dt.String()
//set
err := dt.SetString("yyyy-MM-dd HH:mm:ss")
//get
t := dt.Time()
//set
dt.SetTime(time.Now())
//get
u := dt.Unix()
//set
dt.SetUnix(int64(123))
type st struct {
DT Datetime
}
s := &st{}
//Marshal
j,e := json.Marshal(s)
fmt.Println(string(j)) // {"DT": "yyyy-MM-dd HH:mm:ss"}
//Unmarshal
e := json.UnMarshal([]byte(`{"DT": "yyyy-MM-dd HH:mm:ss"}`), s) // it's ok