date

package
v0.0.40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDays

func AddDays(t time.Time, days int) time.Time

AddDays 将时间加上指定的天数

func AddHours

func AddHours(t time.Time, hours int) time.Time

AddHours 将时间加上指定的小时数

func AddMinutes

func AddMinutes(t time.Time, minutes int) time.Time

AddMinutes 将时间加上指定的分钟数

func AddSeconds

func AddSeconds(t time.Time, seconds int) time.Time

AddSeconds 将时间加上指定的秒数

func CurrentDay

func CurrentDay() int

CurrentDay 获取当前日期

func CurrentHour

func CurrentHour() int

CurrentHour 获取当前时间的小时

func CurrentMinute

func CurrentMinute() int

CurrentMinute 获取当前时间的分钟

func CurrentMonth

func CurrentMonth() time.Month

CurrentMonth 获取当前月份

func CurrentSecond

func CurrentSecond() int

CurrentSecond 获取当前时间的秒钟

func CurrentYear

func CurrentYear() int

CurrentYear 获取当前时间的年份

func EndOfDay

func EndOfDay(t time.Time) time.Time

EndOfDay 获取当前日期的结束时间(23:59:59)

func EndOfMonth

func EndOfMonth(t time.Time) time.Time

EndOfMonth 获取时间的月份结束日期

func EndOfYear

func EndOfYear(t time.Time) time.Time

EndOfYear 获取时间的年份结束日期

func Format

func Format(t time.Time, layout string) string

Format 格式化时间为指定格式字符串

func FormatUnixMilli

func FormatUnixMilli(ts int64, layout string) string

FormatUnixMilli 将 Unix 毫秒时间戳转为指定格式字符串

func FormatUnixNano

func FormatUnixNano(ts int64, layout string) string

FormatUnixNano 将 Unix 纳秒时间戳转为指定格式字符串

func FormatUnixTimestamp

func FormatUnixTimestamp(ts int64, layout string) string

FormatUnixTimestamp 将 Unix(秒) 时间戳转为指定格式字符串

func FromUnixMilli

func FromUnixMilli(ts int64) time.Time

FromUnixMilli 从 Unix 毫秒时间戳转为 time.Time

func FromUnixNano

func FromUnixNano(ts int64) time.Time

FromUnixNano 从 Unix 纳秒时间戳转为 time.Time

func FromUnixTimestamp

func FromUnixTimestamp(ts int64) time.Time

FromUnixTimestamp 将 Unix 时间戳转为 time.Time

func IsAfter

func IsAfter(t time.Time, date time.Time) bool

IsAfter 判断当前时间是否在指定日期之后

func IsBefore

func IsBefore(t time.Time, date time.Time) bool

IsBefore 判断当前时间是否在指定日期之前

func IsSameDay

func IsSameDay(t1, t2 time.Time) bool

IsSameDay 判断当前时间是否是同一天

func IsWeekday

func IsWeekday(t time.Time) bool

IsWeekday 获取当前时间是否在工作日

func IsWeekend

func IsWeekend(t time.Time) bool

IsWeekend 获取当前时间是否在周末

func Parse

func Parse(layout, value string) (time.Time, error)

Parse 解析时间字符串为 time.Time

func Quarter

func Quarter(t time.Time) int

Quarter 获取时间的季度(1~4)

func StartOfDay

func StartOfDay(t time.Time) time.Time

StartOfDay 获取当前日期的开始时间(00:00:00)

func StartOfMonth

func StartOfMonth(t time.Time) time.Time

StartOfMonth 获取时间的月份开始日期

func StartOfYear

func StartOfYear(t time.Time) time.Time

StartOfYear 获取时间的年份开始日期

func TimeDiffInSeconds

func TimeDiffInSeconds(t1, t2 time.Time) int64

TimeDiffInSeconds 获取两者时间差(秒)

func UnixMilli

func UnixMilli() int64

UnixMilli 获取当前 Unix 毫秒时间戳

func UnixNano

func UnixNano() int64

UnixNano 获取当前 Unix 纳秒时间戳

func UnixTimestamp

func UnixTimestamp() int64

UnixTimestamp 获取当前 Unix 时间戳(秒)

func WeekdayName

func WeekdayName(t time.Time) string

WeekdayName 获取时间的星期几(字符串)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL