u
This commit is contained in:
1 parent
d6dd5b032d
commit
8a6d29f5d0
16 files changed
+514
-69
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package timex
|
||||
|
||||
import "time"
|
||||
|
||||
// NowTime 返回当前时间对象(本地时区)
|
||||
func NowTime() time.Time {
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
// NowString 返回当前时间的字符串格式:YYYY-MM-DD HH:mm:ss
|
||||
func NowString() string {
|
||||
return time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
// DateString 返回当前日期(年月日):YYYY-MM-DD
|
||||
func DateString() string {
|
||||
return time.Now().Format("2006-01-02")
|
||||
}
|
||||
|
||||
// TimeString 返回当前时间(时分秒):HH:mm:ss
|
||||
func TimeString() string {
|
||||
return time.Now().Format("15:04:05")
|
||||
}
|
||||
|
||||
// CustomFormat 返回指定格式的当前时间
|
||||
// 例如:timeutil.CustomFormat("2006年01月02日 15时04分05秒")
|
||||
func CustomFormat(format string) string {
|
||||
return time.Now().Format(format)
|
||||
}
|
||||
|
||||
// NowUnix 返回当前时间戳(秒)
|
||||
func NowUnix() int64 {
|
||||
return time.Now().Unix()
|
||||
}
|
||||
|
||||
// NowUnixMilli 返回当前时间戳(毫秒)
|
||||
func NowUnixMilli() int64 {
|
||||
return time.Now().UnixMilli()
|
||||
}
|
||||
Reference in new issue
Block a user