mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 09:16:36 +08:00
21 lines
387 B
Go
21 lines
387 B
Go
package helper
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
func GetTimestamp() int64 {
|
|
return time.Now().Unix()
|
|
}
|
|
|
|
func GetTimeString() string {
|
|
now := time.Now()
|
|
return fmt.Sprintf("%s%d", now.Format("20060102150405"), now.UnixNano()%1e9)
|
|
}
|
|
|
|
// CalcElapsedTime return the elapsed time in milliseconds (ms)
|
|
func CalcElapsedTime(start time.Time) int64 {
|
|
return time.Now().Sub(start).Milliseconds()
|
|
}
|