21 lines
462 B
Go
21 lines
462 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// 获取0点时间戳
|
|
func GetDayStartTimeStamp(t time.Time) int64 {
|
|
loc, err := time.LoadLocation("Asia/Shanghai")
|
|
if err != nil {
|
|
loc = time.FixedZone("CST", 8*3600)
|
|
}
|
|
timeStr := fmt.Sprintf("%02d-%02d-%02d 00:00:00", t.Year(), t.Month(), t.Day())
|
|
duetimecst, err := time.ParseInLocation("2006-1-2 15:04:05", timeStr, loc)
|
|
if err != nil {
|
|
fmt.Printf("parse error : %v\n", err)
|
|
}
|
|
return duetimecst.Unix()
|
|
}
|