time

package
v0.41.8 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Y 2018
	Y int = iota
	// YM  2018-12
	YM
	// YM2 2018/12
	YM2
	// YM3 201812
	YM3
	// YMD 2018-12-31
	YMD
	// YMD2 2018/12/31
	YMD2
	// YMD3 20181231
	YMD3
	// YMDHMS 2018-12-31 12:33:55
	YMDHMS
	// YMDHMS2 2018/12/31 12:33:55
	YMDHMS2
	// YMDHMS3 20181231123355
	YMDHMS3
	// YMDHMSM 2018-12-31 12:33:55.332
	YMDHMSM
	// DEFAULT 2018-12-31 00:03:27
	DEFAULT
)

Variables

This section is empty.

Functions

func After added in v0.34.6

func After(d time.Duration) <-chan time.Time

After time.After

func Date

func Date(level int) string

Date 获取日期,字符串类型 param: level 类型 eg: Date(YMDHMS) => 2018-12-31 12:33:55

func DaySecond added in v0.33.7

func DaySecond(days ...int) int64

DaySecond 获取一天有多少秒

func FirstTimeOfWeek

func FirstTimeOfWeek(year, week int) time.Time

FirstTimeOfWeek 指定年,周 的第一天日期 代码来自于: https://xferion.com/golang-reverse-isoweek-get-the-date-of-the-first-day-of-iso-week/ eg: YearDay(2019, 1) => 2018-12-31 00:00:00 +0800 CST

func Hour

func Hour(hour int) time.Duration

Hour 获取小时

func MS

func MS() int64

MS 获取当前 毫秒 millisecond

func Microsecond added in v0.33.6

func Microsecond(microsecond int) time.Duration

Microsecond 获取微秒

func Millisecond added in v0.33.7

func Millisecond(millisecond int) time.Duration

Millisecond 获取毫秒数

func Minute

func Minute(minute int) time.Duration

Minute 获取分钟

func Nano

func Nano() int64

Nano 获取当前 纳秒

func NextWeekZero

func NextWeekZero() int64

NextWeekZero 下一周第一天零点时间戳 eg: NextWeekZero() => 1546185600

func NextWeekZeroTime

func NextWeekZeroTime() time.Time

NextWeekZeroTime 下一周第一天零点时间 eg: NextWeekZeroTime() => 2018-12-31 00:00:00 +0800 CST

func Now

func Now() int64

Now 获取当前时间戳 秒 eg: Now() => 1543626923

func Pass

func Pass() int64

Pass 今天过去了多少秒 eg: Pass() => 32458

func Remain

func Remain() int64

Remain 今天还剩多少秒 eg: Remain() => 14488

func Second

func Second(second int) time.Duration

Second 获取秒

func Sleep

func Sleep(sleepSecond int)

Sleep 暂停 sleepSecond: 暂停的秒数

func SleepMillisecond added in v0.33.7

func SleepMillisecond(sleepMS int)

SleepMillisecond 暂停 sleepMS: 暂停毫秒数

func SleepMircosecond added in v0.33.7

func SleepMircosecond(sleepMicrosecond int)

SleepMircosecond 暂停 sleepMicrosecond: 暂停微秒数

func Str2Now

func Str2Now(dateString string) int64

Str2Now 将字符串转为时间戳 param: dateString: YYYY-MM-DD hh:mm:ss eg: Str2Now("2018-10-01 00:00:00") => 1538352000

func Str2Time

func Str2Time(dateString string) time.Time

Str2Time 将字符串转为时间 param: dateString YYYY-MM-DD hh:mm:ss eg: Str2Time("2018-10-01 00:00:00") => 2018-10-01 00:00:00 +0000 UTC

func ToString added in v0.28.6

func ToString(timestamp int64, level int) string

ToString 时间戳转字符串

func WS added in v0.41.8

func WS() int64

WS 获取当前 微秒 microsecond

func WeekIndex

func WeekIndex() int

WeekIndex 今天是本周第几天,周一为第一天

func WeekIndexByTime

func WeekIndexByTime(t *time.Time) int

WeekIndexByTime 指定日期为一周的第几天,周一为第一天 返回 1|2|3|4|5|6|7

func WeekPass

func WeekPass() int64

WeekPass 本周已过去多少秒

func WeekRemain

func WeekRemain() int64

WeekRemain 本周还剩多少秒

func WeekZero

func WeekZero() int64

WeekZero 本周第一天零点时间戳 eg: WeekZero() => 1545580800

func WeekZeroTime

func WeekZeroTime() time.Time

WeekZeroTime 本周第一天零点时间 eg: WeekZeroTime() => 2018-12-24 00:00:00 +0800 CST

func YearDay

func YearDay() int

YearDay 今天是今年的第几天 eg: YearDay() => 362

func YearWeek

func YearWeek() (int, int)

YearWeek 获取年份,第几周 eg: YearWeek() => 2018 52

func YearWeekZero

func YearWeekZero(year, week int) int64

YearWeekZero 指定年,周 第一天的零点时间戳 eg: YearWeekZero(2019, 1) => 1546185600

func Zero

func Zero(num int) int64

Zero 获取相差num天的零点时间戳 param: num 相差的天数,可以为负数, 0 表示今天 eg: Zero(-5) =>

func ZeroTime

func ZeroTime(num int) time.Time

ZeroTime 获取相差num天的零点时间 param: num 相差的天数,可以为负数, 0 表示今天 eg: ZeroTime(-5) =>

Types

This section is empty.

Jump to

Keyboard shortcuts

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