package times import "time" var ( cst *time.Location ) func init() { var err error if cst, err = time.LoadLocation("Asia/Shanghai"); err != nil { panic(err) } // 默认设置为中国时区 time.Local = cst } // CSTLayout China Standard Time Layout const CSTLayout = "2006-01-02 15:04:05" func CSTLayoutString() string { ts := time.Now() return ts.In(cst).Format(CSTLayout) }