func GetDayTime(timeType, start, end string) (startTime, endTime int64) {
switch timeType {
case "1": // 昨天
dateNow := time.Now().AddDate(0, 0, -1)
startTime = time.Date(dateNow.Year(), dateNow.Month(), dateNow.Day(), 0, 0, 0, 0, dateNow.Location()).Unix()
endTime = time.Date(dateNow.Year(), dateNow.Month(), dateNow.Day(), 23, 59, 59, 0, dateNow.Location()).Unix()
case "2": // 最近七天
begin := time.Now().AddDate(0, 0, -7)
stop := time.Now().AddDate(0, 0, -1)
startTime = time.Date(begin.Year(), begin.Month(), begin.Day(), 0, 0, 0, 0, begin.Location()).Unix()
endTime = time.Date(stop.Year(), stop.Month(), stop.Day(), 23, 59, 59, 0, stop.Location()).Unix()
case "3": // 最近十五天
begin := time.Now().AddDate(0, 0, -15)
stop := time.Now().AddDate(0, 0, -1)
startTime = time.Date(begin.Year(), begin.Month(), begin.Day(), 0, 0, 0, 0, begin.Location()).Unix()
endTime = time.Date(stop.Year(), stop.Month(), stop.Day(), 23, 59, 59, 0, stop.Location()).Unix()
case "4":
Go-获取指定格式化日期的时间戳范围
最新推荐文章于 2024-01-10 19:14:40 发布

最低0.47元/天 解锁文章
2657

被折叠的 条评论
为什么被折叠?



