package egg_system_rules import "time" func Time2String(date time.Time, format string) string { if format == "" { format = "2006-01-02 15:04:05" } timeS := date.Format(format) if timeS == "0001-01-01 00:00:00" { return "" } return timeS } func String2Time(timeStr string) time.Time { toTime, err := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local) if err != nil { return time.Now() } return toTime } // GetDiffDays 获取两个时间相差的天数,0表同一天,正数表t1>t2,负数表t1