golang 获取上一个月的开始 结束 时间戳
func (s *Service) getLastMonthStartEnd() (int64, int64) {
now := time.Now()
lastMonthFirstDay := now.AddDate(0, -1, -now.Day()+1)
lastMonthStart := time.Date(lastMonthFirstDay.Year(), lastMonthFirstDay.Month(), lastMonthFirstDay.Day(), 0, 0, 0, 0, now.Location()).Unix()
lastMonthEndDay := lastMonthFirstDay.AddDate(0, 1, -1)
lastMonthEnd := time.Date(lastMonthEndDay.Year(), lastMonthEndDay.Month(), lastMonthEndDay.Day(), 23, 59, 59, 0, now.Location()).Unix()
return lastMonthStart, lastMonthEnd
}
lastMonthStart, lastMonthEnd := s.getLastMonthStartEnd()