package mytime import ( "goutil/logUtilPlus" "time" ) // 计算两个时间戳之间间隔多少天 func DiffDays(new, old int64) int64 { newZeroTime := ZeroTime(new, 0) oldZeroTime := ZeroTime(old, 0) logUtilPlus.ErrorLog("newZeroTime=%d,oldZeroTime=%d", newZeroTime, oldZeroTime) return newZeroTime/86400 - oldZeroTime/86400 } func ZeroTime(sec, nsec int64) int64 { dateStr := time.Unix(sec, nsec).Format("2006-01-02") t, _ := time.ParseInLocation("2006-01-02", dateStr, time.Local) return t.Unix() } func IsSameDay(first, second int64) bool { firstZero := ZeroTime(first, 0) secondZero := ZeroTime(second, 0) return firstZero == secondZero }