- time format
This commit is contained in:
@@ -210,7 +210,7 @@ func Timestamp2Time(timestamp int64) time.Time {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Time2Str(t time.Time) string {
|
func Time2Str(t time.Time) string {
|
||||||
return t.Format("2006-1-2 15:4:5")
|
return t.Format("2006-01-02 15:04:05")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Str2Time(timeStr string) time.Time {
|
func Str2Time(timeStr string) time.Time {
|
||||||
@@ -218,7 +218,7 @@ func Str2Time(timeStr string) time.Time {
|
|||||||
if strings.Index(timeStr, " ") == -1 {
|
if strings.Index(timeStr, " ") == -1 {
|
||||||
timeStr += " 00:00:00"
|
timeStr += " 00:00:00"
|
||||||
}
|
}
|
||||||
retVal, err := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local)
|
retVal, err := time.ParseInLocation("2006-1-2 15:4:5", timeStr, time.Local)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
baseapi.SugarLogger.Errorf("time.ParseInLocation failed, timeStr:%v, error:%v", timeStr, err)
|
baseapi.SugarLogger.Errorf("time.ParseInLocation failed, timeStr:%v, error:%v", timeStr, err)
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ func Str2Time(timeStr string) time.Time {
|
|||||||
|
|
||||||
func Str2TimeWithDefault(timeStr string, defValue time.Time) time.Time {
|
func Str2TimeWithDefault(timeStr string, defValue time.Time) time.Time {
|
||||||
timeStr = strings.Replace(timeStr, "T", " ", 1)
|
timeStr = strings.Replace(timeStr, "T", " ", 1)
|
||||||
retVal, err := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local)
|
retVal, err := time.ParseInLocation("2006-1-2 15:4:5", timeStr, time.Local)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return defValue
|
return defValue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user