add time <=> string

This commit is contained in:
david.yan 2025-04-02 14:53:45 +08:00
parent d7fb72b5e0
commit 7983651fcd
1 changed files with 14 additions and 0 deletions

14
utils/time.go Normal file
View File

@ -0,0 +1,14 @@
package utils
import (
"time"
)
func Time2String(layout string, t time.Time) string {
return t.Format(layout)
}
func String2Time(layout, in string) time.Time {
t, _ := time.ParseInLocation(layout, in, time.Local)
return t
}