golang获取每日固定时间

2020-04-14  本文已影响0人  清歌从酒
    day :=1
    now := time.Now().Local() //获取当前时间,放到now里面,要给next用  
duration:=time.Hour*time.Duration(day)*24
extendTimeFormat := now.Add(duration).Format("2006-01-02 00:00:00") 
stamp, _ := time.ParseInLocation("2006-01-02 15:04:05", extendTimeFormat, time.Local)
stampTime := stamp.Unix()-1//
stampTimeStr := time.Unix(stampTime, 0).Format("2006-01-02 15:04:05")

endTime, _ = time.ParseInLocation("2006-01-02 15:04:05", stampTimeStr, time.Local)
结果 : image.png
上一篇 下一篇

猜你喜欢

热点阅读