types.go
277 Bytes
package main
import (
"time"
)
type Time time.Time
func (t *Time) Scan(v interface{}) error {
p, err := time.Parse("2006-01-02 15:04:05", string(v.([]byte)))
*t = Time(p)
return err
}
func (t *Time) MarshalJSON() ([]byte, error) {
return time.Time(*t).MarshalJSON()
}