diff --git a/utils/time_utils.go b/utils/time_utils.go index 7ca182236..a6e29ea39 100644 --- a/utils/time_utils.go +++ b/utils/time_utils.go @@ -34,3 +34,24 @@ func GiveMeMilliseconds(c int64) time.Duration { func GiveMeMicroseconds(c int64) time.Duration { return time.Microsecond * time.Duration(c) } + +// NowTs 返回当前Unix时间戳 +func NowTs() int64 { + return time.Now().Unix() +} + +// NowTime 返回当前时间串,eg: 2023-07-10 13:14:52 +func NowTime() string { + return time.Now().Format("2006-01-02 15:04:05") +} + +// Sleep 当前线程阻塞(休眠)指定时间,单位:毫秒 +func Sleep(ts int) { + time.Sleep(time.Millisecond * time.Duration(ts)) +} + +// Zone 返回当前时区 +func Zone() string { + zone, _ := time.Now().Zone() + return zone +}