[agent-wdd] 完成自定义log部分;完成info network部分; 项目结构基本完成
This commit is contained in:
24
agent-wdd/utils/TimeUtils.go
Normal file
24
agent-wdd/utils/TimeUtils.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
const defaultTimeString = "2011-11-11 11:11:11"
|
||||
|
||||
func CurrentTimeString() string {
|
||||
|
||||
// 加载东八区时区
|
||||
loc, err := time.LoadLocation("Asia/Shanghai")
|
||||
if err != nil {
|
||||
fmt.Println("无法加载时区:", err)
|
||||
return defaultTimeString
|
||||
}
|
||||
|
||||
// 获取当前时间并转换为东八区时间
|
||||
now := time.Now().In(loc)
|
||||
// 格式化为 "2006-01-02 15:04:05" 的布局
|
||||
formattedTime := now.Format(time.DateTime)
|
||||
return formattedTime
|
||||
}
|
||||
Reference in New Issue
Block a user