timestamp

package
v1.19.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Package timestamp 本地时间戳相关功能

Index

Constants

View Source
const (
	SecondsPerMinute      = 60
	SecondsPerHour        = 60 * SecondsPerMinute
	SecondsPerDay         = 24 * SecondsPerHour
	MillisecondsPerSecond = 1000
	MillisecondsPerMinute = SecondsPerMinute * MillisecondsPerSecond
	MillisecondsPerHour   = SecondsPerHour * MillisecondsPerSecond
	MillisecondsPerDay    = SecondsPerDay * MillisecondsPerSecond
)

Variables

This section is empty.

Functions

func CurrentDateZero

func CurrentDateZero(t time.Time) time.Time

CurrentDateZero t日期的0点整

func Now

func Now() int64

Now 获取本地当前的时间戳, 毫秒数

UTC 转 local

func Since

func Since(t time.Time) int64

Since t当日0点整到t的毫秒数

func SinceZero

func SinceZero(milliseconds int64) int64

SinceZero 从0点到milliseconds过去的毫秒数

func SinceZeroHour

func SinceZeroHour(t time.Time) int64

SinceZeroHour t当天0点开始到t时的毫秒数

func Time

func Time(milliseconds int64) time.Time

Time 本地毫秒数转time.Time

local 转 UTC

func TimeToTimestamp added in v1.19.5

func TimeToTimestamp(t time.Time) int64

TimeToTimestamp 获取time.Time的本地毫秒数

UTC 转 local

func Today

func Today() int64

Today 获取当日0点整的时间戳, 毫秒数

UTC 转 local

func TodayZero

func TodayZero() time.Time

TodayZero 这也是一个当日0点的用法

func ZeroHour

func ZeroHour(milliseconds int64) int64

ZeroHour 零点整的毫秒数

Types

type Timestamp

type Timestamp int64

Timestamp 时间戳类型

func (Timestamp) DateTime added in v1.19.5

func (t Timestamp) DateTime() (year, month, day, hour, minute, second, millisecond int)

DateTime 获取日期时间毫秒

func (Timestamp) String added in v1.19.5

func (t Timestamp) String() string

Jump to

Keyboard shortcuts

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