starttime

This commit is contained in:
jiangyong 2026-09-16 00:32:57 +08:00
parent fe4cda2ff8
commit 6a82cda1af
1 changed files with 6 additions and 4 deletions

10
time.go
View File

@ -50,8 +50,9 @@ func GetNowTime() string {
// 获取一天开始的时间戳
func GetTodayStartTime() int64 {
now := time.Now().Unix()
return now - (now+28800)%86400
now := time.Now()
t := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
return t.Unix()
}
// 获取一周开始的时间戳
@ -67,8 +68,9 @@ func GetWeekStartTime() int64 {
// 获取一月开始的时间戳
func GetMonthStartTime() int64 {
now := time.Now().AddDate(0, 0, 1-time.Now().Day()).Unix()
return now - (now+28800)%86400
now := time.Now()
t := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
return t.Unix()
}
func TimeToWeek(t int64) string {