From 61b3c5c7cc455503f59f8e4bd726cb3da69cbb6f Mon Sep 17 00:00:00 2001 From: hoteas Date: Tue, 8 Nov 2022 16:05:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/objtoobj.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 {