time

package
v0.10.20 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatDateTime = "2006-01-02 15:04:05"
	FormatDate     = "2006-01-02"
	FormatTime     = "15:04:05"

	LayoutDateTime    = "2006-01-02 15:04:05"
	LayoutDate        = "2006-01-02"
	LayoutTime        = "15:04:05"
	LayoutDateTimeNum = "20060102150405"

	TimeZoneSH = "Asia/Shanghai"
)

Variables

View Source
var (
	TimeZero = Time(time.Time{})
	TimeNow  = Time(time.Now())
)

Functions

func CheckSETime added in v0.9.7

func CheckSETime(startTime, endTime string) bool

CheckSETime 检查开始时间和结束时间

func IntToString

func IntToString(t int) string

IntToString 将int转换为时间字符串 例如: 1560000000 -> 2019-06-09 00:00:00

func IntToStringDate

func IntToStringDate(t int) string

IntToStringDate 将int转换为日期字符串 例如: 1560000000 -> 2019-06-09

func IntToStringTime

func IntToStringTime(t int) string

IntToStringTime 将int转换为时间字符串 例如: 1560000000 -> 00:00:00

func NowMilliTimeStamp added in v0.10.0

func NowMilliTimeStamp() int64

NowMilliTimeStamp 获取当前时间戳(毫秒) 例如: 1560000000000

func NowTimeStamp added in v0.2.3

func NowTimeStamp() int

NowTimeStamp 获取当前时间戳 例如: 1560000000

func NowTimeStr added in v0.2.3

func NowTimeStr() string

NowTimeStr 获取当前时间字符串 例如: 2019-06-09 00:00:00

func StringToInt

func StringToInt(t string) int

StringToInt 将时间字符串转换为int 例如: 2019-06-09 00:00:00 -> 1560000000

Types

type JsonTime

type JsonTime time.Time

func (JsonTime) MarshalJSON

func (t JsonTime) MarshalJSON() ([]byte, error)

type Time added in v0.1.6

type Time time.Time // 和JsonTime一样,只是为了方便使用

func Now added in v0.7.0

func Now() Time

func StringToTime added in v0.10.4

func StringToTime(t string) Time

StringToTime 将时间字符串转换为time 例如: 2019-06-09 00:00:00 -> time

func (Time) Format added in v0.7.0

func (t Time) Format(layout string) string

func (Time) IsToday added in v0.10.5

func (t Time) IsToday() bool

IsToday 判断是否今天

func (Time) IsYesterday added in v0.10.5

func (t Time) IsYesterday() bool

IsYesterday 判断是否昨天

func (Time) IsZero added in v0.6.4

func (t Time) IsZero() bool

func (Time) MarshalJSON added in v0.1.6

func (t Time) MarshalJSON() ([]byte, error)

func (Time) Raw added in v0.10.4

func (t Time) Raw() time.Time

Raw 返回原始time.Time

Jump to

Keyboard shortcuts

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