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.
23 lines
419 B
23 lines
419 B
2 years ago
|
package util
|
||
|
|
||
|
import "time"
|
||
|
|
||
|
// GetNowYmdHms 获取当前datetime
|
||
|
func GetNowYmdHms() string {
|
||
|
return time.Now().Format("2006-01-02 15:04:05")
|
||
|
}
|
||
|
|
||
|
// GetNowUnix 获取当前时间戳
|
||
|
func GetNowUnix() int64 {
|
||
|
return time.Now().Unix()
|
||
|
}
|
||
|
|
||
|
func TraTime(t time.Time) int64 {
|
||
|
return t.Unix()
|
||
|
}
|
||
|
|
||
|
func TraStrToUnix(val string) int64 {
|
||
|
t, _ := time.ParseInLocation("2006-01-02 15:04:05", val, time.Local)
|
||
|
return t.Unix()
|
||
|
}
|