diff --git a/common/objtoobj.go b/common/objtoobj.go index f1d3201..d1c1d2d 100644 --- a/common/objtoobj.go +++ b/common/objtoobj.go @@ -5,6 +5,7 @@ import ( "errors" "math" "strconv" + "strings" "time" ) @@ -103,7 +104,22 @@ func ObjToTime(obj interface{}, e ...*Error) time.Time { //字符串类型,只支持标准mysql datetime格式 if tInt == 0 { tStr := ObjToStr(obj) - + timeNewStr := "" + timeNewStrs := strings.Split(tStr, "-") + for _, v := range timeNewStrs { + if v == "" { + continue + } + if len(v) == 1 { + v = "0" + v + } + if timeNewStr == "" { + timeNewStr = v + continue + } + timeNewStr = timeNewStr + "-" + v + } + tStr = timeNewStr if len(tStr) > 18 { t, e := time.Parse("2006-01-02 15:04:05", tStr) if e == nil {