Commit 0ef6cd6c authored by chenweijian's avatar chenweijian

获取上个月开始时间

parent 1c8db43f
......@@ -59,3 +59,10 @@ func AddDate(t time.Time, years int, months int) time.Time {
func DayRemainSecond(date time.Time) int64 {
return time.Date(date.Year(), date.Month(), date.Day(), 23, 59, 59, 999, date.Location()).Unix() - date.Unix()
}
func GetLastMonthStart(t time.Time) time.Time {
thisMonthStart := time.Date(t.Year(), t.Month(), 1, 0, 0, 0, 0, t.Location())
lastDay := thisMonthStart.AddDate(0, 0, -1)
lastMonthStart := time.Date(lastDay.Year(), lastDay.Month(), 1, 0, 0, 0, 0, t.Location())
return lastMonthStart
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment