package main import ( "git.hilo.cn/hilo-common/mylogrus" "git.hilo.cn/hilo-common/script/mysql" "time" ) type GiftOperate struct { ResGiftId uint64 GiftN uint64 SendUserId uint64 ReceiveUserId uint64 SendUserDiamond uint64 ReceiveUserDiamond uint64 ReceiveUserBean uint64 SceneUid string BagId uint64 ID uint64 `gorm:"primary_key"` CreatedTime time.Time `gorm:"->"` UpdatedTime time.Time `gorm:"->"` } func main() { var gift GiftOperate if err := mysql.ProdReadOnlyDB.Table("gift_operate_2").Order("id ASC").First(&gift).Error; err != nil { mylogrus.MyLog.Errorf("GiftOperateTable fail:%v", err) panic("e") } println(time.Now().Sub(gift.CreatedTime).Hours()) if !gift.CreatedTime.IsZero() && time.Now().Sub(gift.CreatedTime) >= time.Hour*24*90 && time.Now().Hour() == 10 { // newTable已经过去90天 println(true) } else { println(false) } }