You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
835 B
30 lines
835 B
package utils
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func GetTimeRangeByMinute(durationMinute int) (start, stop string) {
|
|
|
|
start = time.Now().Add(time.Minute * -1 * time.Duration(durationMinute)).Format("2006-01-02T15:04:00+08:00")
|
|
stop = time.Now().Format("2006-01-02T15:04:00+08:00")
|
|
return
|
|
}
|
|
|
|
func GetTimeRangeByHour(durationHour int) (start, stop string) {
|
|
|
|
start = time.Now().Add(time.Hour * time.Duration(durationHour)).Format("2006-01-02T15:00:00.000+08:00")
|
|
stop = time.Now().Format("2006-01-02T15:04:00.000+08:00")
|
|
return
|
|
}
|
|
|
|
func GetTimeRangeBy10min() (start, stop string) {
|
|
|
|
m := time.Now().Minute() % 10
|
|
log.Println(m)
|
|
startTime := time.Now().Add(time.Minute * -1 * time.Duration(m))
|
|
start = startTime.Add(time.Minute * -10).Format("2006-01-02T15:04:00+08:00")
|
|
stop = startTime.Format("2006-01-02T15:04:00+08:00")
|
|
return
|
|
}
|
|
|