Skip to content

Commit

Permalink
feat: support more time function
Browse files Browse the repository at this point in the history
  • Loading branch information
qubbei authored Jul 19, 2023
1 parent 44def99 commit c4266c0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions utils/time_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit c4266c0

Please sign in to comment.