time

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DataFormat day
	DataFormat = "2006-01-02"
	// DataTimeFormat minute
	DataTimeFormat = "2006-01-02 15:0"
	// DataTimeFormatSecond second
	DataTimeFormatSecond = "2006-01-02 15:04:05"
	// DataTimeFormatSecond2 second
	DataTimeFormatSecond2 = "2006-01-02T15:04:05"
	// DataTimeFormatSecondUTCLocation second location UTC
	DataTimeFormatSecondUTCLocation = "2006-01-02T15:04:05Z"
	// DataTimeFormatMilliSecond milli Second location
	DataTimeFormatMilliSecond = "2006-01-02T15:04:05.000000"
)

Variables

This section is empty.

Functions

func ParseTime

func ParseTime(t, layout string, loc ...*time.Location) (tt time.Time, err error)

ParseTime 将时间字符串按 layout 格式转换为时间格式

func ParseTimeInt64

func ParseTimeInt64(t, layout string, loc ...*time.Location) (tInt64 int64, err error)

ParseTimeInt64 将时间字符串按 layout 格式转换为时间戳格式,毫秒

func ParseTimeToLocal

func ParseTimeToLocal(t, layout string, loc ...*time.Location) (localTime time.Time, err error)

ParseTimeToLocal 将时区时间转换为当前服务器时间,例如 UTC 时区 2021-06-13T00:00:00Z 将转化为 2021-06-13T08:00:00Z

func ParseTimeToUTC

func ParseTimeToUTC(t, layout string, loc ...*time.Location) (utcTime time.Time, err error)

ParseTimeToUTC 将时区时间转换为UTC时区时间

func ParseTimeUnix

func ParseTimeUnix(time time.Time, unixType UnixType) (tInt64 int64, err error)

ParseTimeUnix 转换为时间戳

func ParseUTCMillSecond

func ParseUTCMillSecond(t, layout string) (tInt64 int64, err error)

ParseUTCMillSecond 将 UTC 字符串转换成 local time 毫秒

func ParseUnix

func ParseUnix(t, layout string, unixType UnixType, loc ...*time.Location) (tInt64 int64, err error)

ParseUnix 转换为时间戳

Types

type UnixType

type UnixType string

UnixType 时间戳精度

const (
	SecondUnix      UnixType = "SecondUnix"      // 秒
	MilliSecondUnix UnixType = "MilliSecondUnix" // 毫秒
	NanoSecondUnix  UnixType = "NanoSecondUnix"  // 纳秒
)

时间戳精度 Enum

Jump to

Keyboard shortcuts

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