Documentation
¶
Index ¶
- Constants
- func AddDays(t time.Time, days int) time.Time
- func AddMonths(t time.Time, months int) time.Time
- func DateToTime(format, date string) (time.Time, error)
- func DaysBetween(a, b time.Time) int
- func DaysInMonth(year int, month time.Month) int
- func EndOfDay(t time.Time) time.Time
- func FormatRFC3339(t time.Time) string
- func FriendlyDuration(d time.Duration) string
- func IsAfter(a, b time.Time) bool
- func IsBefore(a, b time.Time) bool
- func IsBetween(t, start, end time.Time) bool
- func IsExpired(t time.Time) bool
- func IsLeapYear(year int) bool
- func IsThisMonth(t time.Time) bool
- func IsThisWeek(t time.Time) bool
- func IsThisYear(t time.Time) bool
- func IsToday(t time.Time) bool
- func IsWeekend(t time.Time) bool
- func IsWorkday(t time.Time) bool
- func IsYesterday(t time.Time) bool
- func IsZero(t time.Time) bool
- func MillisToTime(ms int64) time.Time
- func MonthEnd(t time.Time) time.Time
- func StartOfDay(t time.Time) time.Time
- func ThisMonth(t time.Time) time.Time
- func ThisYear(t time.Time) time.Time
- func Time9999() time.Time
- func TimeAgo(t time.Time) string
- func TimestampMicros() int64
- func TimestampMillis() int64
- func TimestampToDate(u int64, format string) string
- func TimestampToTime(u int64) time.Time
- func ToDay(t time.Time) time.Time
- func ToHour(t time.Time) time.Time
- func ToMinute(t time.Time) time.Time
- func Today() time.Time
- func WeekEnd(t time.Time) time.Time
- func WeekStart(t time.Time) time.Time
Constants ¶
View Source
const ( RFC3339 = time.RFC3339 // 例子:2022-08-03T16:40:58+08:00 YmdHmsTZ = "2006-01-02T15:04:05-0700" // 例子:2022-08-03T16:40:58+0800 YmdHms = "2006-01-02 15:04:05" YmdHm = "2006-01-02 15:04" YmdH = "2006-01-02 15" Ymd = "2006-01-02" Ym = "2006-01" Y = "2006" YSecond = "20060102150405" YMinute = "200601021504" YHour = "2006010215" YDay = "20060102" YMonth = "200601" MDay = "0102" YmdHmsMillisecond = "2006-01-02 15:04:05.999" YmdHmsMicrosecond = "2006-01-02 15:04:05.999999" YmdHmsNanosecond = "2006-01-02 15:04:05.999999999" YMillisecond = "20060102150405.999" YMicrosecond = "20060102150405.999999" YNanosecond = "20060102150405.999999999" YmdHmsMLogger = "2006-01-02T15:04:05.999" YmdHmsChinese = "2006年01月02日 15:04:05" YmdChinese = "2006年01月02日" HmsChinese = "15时04分05秒" )
Date Format
Variables ¶
This section is empty.
Functions ¶
func DaysBetween ¶
DaysBetween 计算两个时间之间的天数差(绝对值) 使用 UTC 日期差计算,避免夏令时导致的小时偏差
func FriendlyDuration ¶
FriendlyDuration 将 Duration 转为友好的中文描述 例如:1h30m → "1小时30分钟",72h → "3天"
func TimestampToDate ¶
TimestampToDate timestamp to date
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.