Documentation
¶
Overview ¶
Package timex 提供常用的时间操作工具函数。
包含时间戳转换、日期格式化、时区处理等功能。
Index ¶
- func ConvertTimezone(datetime string, fromLoc string) (string, error)
- func Date2Stamp(date string, format string) int64
- func GetCurrentDate(format string) string
- func GetCurrentDayStartTime() int64
- func GetCurrentTime() int
- func NDateBefore(n int, isMulti bool, format string) []string
- func StampInt2Date(timestamp int64, format string) string
- func StampString2Date(timestampStr, format string) string
- func TimestampString() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertTimezone ¶
ConvertTimezone 将日期时间从指定时区转换为本地时区。
func Date2Stamp ¶
Date2Stamp 将日期字符串转换为 Unix 时间戳。 使用本地时区解析(time.ParseInLocation),避免 UTC 偏移问题。 解析失败时返回 0。
func GetCurrentDate ¶
GetCurrentDate 返回当前日期字符串,默认格式为 "2006-01-02"。
func GetCurrentDayStartTime ¶
func GetCurrentDayStartTime() int64
GetCurrentDayStartTime 返回今天 00:00:00 的 Unix 时间戳。
func NDateBefore ¶
NDateBefore 获取前 n 天的日期列表。 isMulti 为 true 时返回前 n 天每一天的日期,否则只返回第 n 天的日期。
func StampInt2Date ¶
StampInt2Date 将 Unix 时间戳转换为日期格式。
func StampString2Date ¶
StampString2Date 将时间戳字符串转换为日期格式。 解析失败时返回空字符串。
func TimestampString ¶
func TimestampString() string
TimestampString 返回当前 Unix 时间戳的字符串。 时间戳始终为 UTC 秒数,不含时区偏移(Unix 时间戳是时区无关的)。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.