mc-client-updater-server/pkg/util/time.go

24 lines
469 B
Go
Raw Normal View History

2024-01-07 15:13:35 +08:00
package util
import "time"
func ToSQLTimeFormat(t time.Time) string {
return t.Format("2006-01-02 15:04:05")
}
func MustParseSQLTime(timeStr string) time.Time {
timeObj, err := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local)
if err != nil {
panic(err)
}
return timeObj
}
func IsSQLTimeFormat(timeStr string) bool {
_, err := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local)
if err != nil {
return false
}
return true
}