timeutil

package module
v0.0.0-...-4fa02e0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: GPL-3.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(date time.Time, iT ...int) time.Time

* * 获取指定分钟后的时间 * @param date 起始时间 * @param iT 时间参数,分别是年、月、日、时、分、秒 * @return

func AddDay

func AddDay(date time.Time, iCount int) time.Time

* * 获取指定天数后的时间 * @param date 起始时间 * @param iCount 天数 * @return

func AddHour

func AddHour(date time.Time, iCount int) time.Time

* * 获取指定小时后的时间 * @param date 起始时间 * @param iCount 小时数 * @return

func AddMinute

func AddMinute(date time.Time, iCount int) time.Time

* * 获取指定分钟后的时间 * @param date 起始时间 * @param iCount 分数 * @return

func AddMonth

func AddMonth(date time.Time, iCount int) time.Time

* * 获取指定月后的时间 * @param date 起始时间 * @param iCount 月数 * @return

func AddYear

func AddYear(date time.Time, iCount int) time.Time

* * 获取指定年后的时间 * @param date 起始时间 * @param iCount 年数 * @return

func Current

func Current(formatStr ...string) string

取当前时间

func Format

func Format(date time.Time, formatStr string) string

时间格式化

func GapDay

func GapDay(t1, t2 interface{}) (day int)

计算日期相差多少天(注意:3到6差距是3而不是4)

func GapHour

func GapHour(t1, t2 interface{}) (hour int)

计算日期相差多少小时(注意:3到6差距是3而不是4)

func GapMinute

func GapMinute(t1, t2 interface{}) (hour int)

计算日期相差多少分钟(注意:3到6差距是3而不是4)

func GapMonth

func GapMonth(t1, t2 interface{}) (month int)

计算日期相差多少月(注意:3到6差距是3而不是4)

func GapYear

func GapYear(t1, t2 interface{}) (year int)

计算日期相差多少年(注意:3到6差距是3而不是4)

func IsTime

func IsTime(str string) bool

判断字符串是否是日期型

func MilliSecond

func MilliSecond() int64

取时间戳(毫秒)

func NanoSecond

func NanoSecond() int64

取时间戳(纳秒)

func Second

func Second() int64

取时间戳(秒)

func ToDate

func ToDate(str string) time.Time

字符串转时间

func Today

func Today(formatStr ...string) string

取今天日期

func TodayEd

func TodayEd() string

取今天结束时间

func TodaySt

func TodaySt() string

取今天开始时间

Types

type Time

type Time time.Time

自定义时间类型

func (*Time) MarshalJSON

func (tu *Time) MarshalJSON() ([]byte, error)

重写MarshalJSON方法来实现gorm查询时间字段事数据解析

func (Time) Now

func (tu Time) Now() Time

取当前时间

func (*Time) Scan

func (tu *Time) Scan(v interface{}) error

在数据查询出来之前对数据进⾏相关操作

func (Time) String

func (tu Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳