package util import "time" // GetNowYmdHms 获取当前datetime func GetNowYmdHms() string { return time.Now().Format("2006-01-02 15:04:05") } // GetNowUnix 获取当前时间戳 func GetNowUnix() int64 { return time.Now().Unix() } func TraTime(t time.Time) int64 { return t.Unix() } func TraStrToUnix(val string) int64 { t, _ := time.ParseInLocation("2006-01-02 15:04:05", val, time.Local) return t.Unix() }