datetime

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MIT Imports: 2 Imported by: 23

Documentation

Overview

Package datetime implements some functions to format date and time. Note: 1. `format` param in FormatTimeToStr function should be as flow: "yyyy-mm-dd hh:mm:ss" "yyyy-mm-dd hh:mm" "yyyy-mm-dd hh" "yyyy-mm-dd" "yyyy-mm" "mm-dd" "dd-mm-yy hh:mm:ss" "yyyy/mm/dd hh:mm:ss" "yyyy/mm/dd hh:mm" "yyyy/mm/dd hh" "yyyy/mm/dd" "yyyy/mm" "mm/dd" "dd/mm/yy hh:mm:ss" "yyyy" "mm" "hh:mm:ss" "mm:ss"

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 BeginOfDay

func BeginOfDay(t time.Time) time.Time

BeginOfDay return beginning hour time of day

func BeginOfHour

func BeginOfHour(t time.Time) time.Time

BeginOfHour return beginning hour time of day

func BeginOfMinute

func BeginOfMinute(t time.Time) time.Time

BeginOfMinute return beginning minute time of day

func BeginOfMonth

func BeginOfMonth(t time.Time) time.Time

BeginOfMonth return beginning of month

func BeginOfWeek

func BeginOfWeek(t time.Time) time.Time

BeginOfWeek return beginning week, week begin from Sunday

func BeginOfYear

func BeginOfYear(t time.Time) time.Time

BeginOfYear return beginning of year

func EndOfDay

func EndOfDay(t time.Time) time.Time

EndOfDay return end time of day

func EndOfHour

func EndOfHour(t time.Time) time.Time

EndOfHour return end hour time of day

func EndOfMinute

func EndOfMinute(t time.Time) time.Time

EndOfMinute return end minute time of day

func EndOfMonth

func EndOfMonth(t time.Time) time.Time

EndOfMonth return end of month

func EndOfWeek

func EndOfWeek(t time.Time) time.Time

EndOfWeek return end week time, week end with Saturday

func EndOfYear

func EndOfYear(t time.Time) time.Time

EndOfYear return end of year

func FormatStrToTime

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

FormatStrToTime convert string to time

func FormatTimeToStr

func FormatTimeToStr(t time.Time, format 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 NewFormat added in v2.0.1

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 v2.0.1

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

NewISO8601 return unix timestamp of specified iso8601 time string

func NewUnix added in v2.0.1

func NewUnix(unix int64) *theTime

NewUnix return unix timestamp of specified time

func NewUnixNow added in v2.0.1

func NewUnixNow() *theTime

NewUnixNow return unix timestamp of current time

Types

This section is empty.

Jump to

Keyboard shortcuts

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