From 0ef6cd6cc24d71b274d12df234d0c46991f3df1d Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Thu, 20 Apr 2023 11:52:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8A=E4=B8=AA=E6=9C=88?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/time.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/time.go b/utils/time.go index 3044826..d2e3476 100644 --- a/utils/time.go +++ b/utils/time.go @@ -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 +} -- 2.22.0