datetime

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDay

func AddDay(t time.Time, day int64) time.Time

AddDay add or sub day to the time

func AddHour

func AddHour(t time.Time, hour int64) time.Time

AddHour add or sub hour to the time

func AddMinute

func AddMinute(t time.Time, minute int64) time.Time

AddMinute add or sub minute to the time

func AddYear added in v1.3.9

func AddYear(t time.Time, year int64) time.Time

AddYear add or sub year to the time.

func BeginOfDay added in v1.2.4

func BeginOfDay(t time.Time) time.Time

BeginOfDay return beginning hour time of day

func BeginOfHour added in v1.2.4

func BeginOfHour(t time.Time) time.Time

BeginOfHour return beginning hour time of day

func BeginOfMinute added in v1.2.4

func BeginOfMinute(t time.Time) time.Time

BeginOfMinute return beginning minute time of day

func BeginOfMonth added in v1.2.4

func BeginOfMonth(t time.Time) time.Time

BeginOfMonth return beginning of month

func BeginOfWeek added in v1.2.4

func BeginOfWeek(t time.Time) time.Time

BeginOfWeek return beginning week, week begin from Sunday

func BeginOfYear added in v1.2.4

func BeginOfYear(t time.Time) time.Time

BeginOfYear return beginning of year

func BetweenSeconds added in v1.3.9

func BetweenSeconds(t1 time.Time, t2 time.Time) int64

BetweenSeconds returns the number of seconds between two times.

func DayOfYear added in v1.3.9

func DayOfYear(t time.Time) int

DayOfYear returns which day of the year the parameter date `t` is.

func EndOfDay added in v1.2.4

func EndOfDay(t time.Time) time.Time

EndOfDay return end time of day

func EndOfHour added in v1.2.4

func EndOfHour(t time.Time) time.Time

EndOfHour return end hour time of day

func EndOfMinute added in v1.2.4

func EndOfMinute(t time.Time) time.Time

EndOfMinute return end minute time of day

func EndOfMonth added in v1.2.4

func EndOfMonth(t time.Time) time.Time

EndOfMonth return end of month

func EndOfWeek added in v1.2.4

func EndOfWeek(t time.Time) time.Time

EndOfWeek return end week time, week end with Saturday

func EndOfYear added in v1.2.4

func EndOfYear(t time.Time) time.Time

EndOfYear return end of year

func FormatStrToTime

func FormatStrToTime(str, format string, timezone ...string) (time.Time, error)

FormatStrToTime convert string to time

func FormatTimeToStr

func FormatTimeToStr(t time.Time, format string, timezone ...string) string

FormatTimeToStr convert time to string

func GetNightTimestamp

func GetNightTimestamp() int64

GetNightTimestamp return timestamp of zero hour (timestamp of 23:59)

func GetNowDate

func GetNowDate() string

GetNowDate return format yyyy-mm-dd of current date

func GetNowDateTime

func GetNowDateTime() string

GetNowDateTime return format yyyy-mm-dd hh-mm-ss of current datetime

func GetNowTime

func GetNowTime() string

GetNowTime return format hh-mm-ss of current time

func GetZeroHourTimestamp

func GetZeroHourTimestamp() int64

GetZeroHourTimestamp return timestamp of zero hour (timestamp of 00:00)

func IsLeapYear added in v1.3.9

func IsLeapYear(year int) bool

IsLeapYear check if param year is leap year or not.

func IsWeekend added in v1.3.9

func IsWeekend(t time.Time) bool

IsWeekend checks if passed time is weekend or not.

func NewFormat added in v1.2.7

func NewFormat(t string) (*theTime, error)

NewFormat return unix timestamp of specified time string, t should be "yyyy-mm-dd hh:mm:ss"

func NewISO8601 added in v1.2.7

func NewISO8601(iso8601 string) (*theTime, error)

NewISO8601 return unix timestamp of specified iso8601 time string

func NewUnix added in v1.2.7

func NewUnix(unix int64) *theTime

NewUnix return unix timestamp of specified time

func NewUnixNow added in v1.2.7

func NewUnixNow() *theTime

NewUnixNow return unix timestamp of current time

func NowDateOrTime added in v1.4.1

func NowDateOrTime(format string, timezone ...string) string

NowDateOrTime return current datetime with specific format and timezone.

func Timestamp added in v1.4.1

func Timestamp(timezone ...string) int64

Timestamp return current second timestamp.

func TimestampMicro added in v1.4.1

func TimestampMicro(timezone ...string) int64

TimestampMicro return current micro second timestamp.

func TimestampMilli added in v1.4.1

func TimestampMilli(timezone ...string) int64

TimestampMilli return current mill second timestamp.

func TimestampNano added in v1.4.1

func TimestampNano(timezone ...string) int64

TimestampNano return current nano second timestamp.

Types

This section is empty.

Jump to

Keyboard shortcuts

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