gotime

package
v1.2.162 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

时间日期相关工具函数

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeLayout string = "2006-01-02 15:04:05"
	DateLayout        = "20060102"
	TimeFormat        = map[string]string{
		"Y-m-d H:i:s": "2006-01-02 15:04:05",
		"Y-m-d":       "2006-01-02",
		"Ymd":         "20060102",
		"H:i:s":       "15:04:05",
		"Y":           "2006",
		"m":           "01",
		"d":           "02",
	}
)

Functions

func BeijingTimeLocation

func BeijingTimeLocation() *time.Location

func ConvertAmPmHourTo24HourFormat

func ConvertAmPmHourTo24HourFormat(timeStr string, layout24Hour string) (string, error)

convertTo24HourFormat 将时间字符串转换为 0-23 小时制 timeStr: 时间字符串,例如 "3:04 PM" 3:04 PM-->15:04 ,必须是这两个格式之一

func ConvertToGMTTime

func ConvertToGMTTime(gmtTime string) (time.Time, error)

格式为: 2021-08-06T07:00:00+0000 To time.Time

func CurrentHourStartAndEnd

func CurrentHourStartAndEnd() (int, int64, int64)

func Date2Ts

func Date2Ts(date string) int64

func Date2TsLocal

func Date2TsLocal(date string, location *time.Location) int64

func DateTime

func DateTime(format string) string

当前时区相关日期函数

func DateTime2Ts

func DateTime2Ts(dateTime string) int64

func DateTime2TsLocal

func DateTime2TsLocal(dateTime string, location *time.Location) int64

func DateTime2TsLocalFormat

func DateTime2TsLocalFormat(dateTime string, location *time.Location, format string) int64

func DateTimeLocal

func DateTimeLocal(format string, timeOffsetSec int) string

当前时间通用 格式用法

func DatesForRangeTs

func DatesForRangeTs(startTimestamp int64, endTimestamp int64, format string) []string

func GetChinaTomorrowAMSeconds

func GetChinaTomorrowAMSeconds(isBeijing bool) int64

func GetDateInterval

func GetDateInterval(t1, t2 time.Time) int

func GetLocalTomorrowAMSeconds

func GetLocalTomorrowAMSeconds() int64

func GetNowDateForLocation

func GetNowDateForLocation(isBeijing bool) string

func GetTimeNow

func GetTimeNow() time.Time

GetTimeNow 获取当前时间GetTimeNow(),用于测试时的时间修改

func GetTodayZero

func GetTodayZero() time.Time

func GetZero

func GetZero(targetTime time.Time) time.Time

func IsSameDay

func IsSameDay(t1, t2 time.Time) bool

func IsValidDate

func IsValidDate(str string) bool

func IsValidDateTime

func IsValidDateTime(str string) bool

判断是不是 2024-11-22 4 格式的时间串

func LastHourStartAndEnd

func LastHourStartAndEnd(isBeijing bool) (int, int64, int64)

LastHourStartAndEnd 上一个小时的开始和结束时间戳

func NextDate

func NextDate(d int) string

func NextDateLocal

func NextDateLocal(d int, timeOffsetSec int) string

NextDate

func Now

func Now() string

func NowLocal

func NowLocal(timeOffsetSec int) string

NowDateTime

func ParseTime

func ParseTime(timeStr string) (datetime time.Time)

ParseTime 解析时间,"2021-03-17 00:00:00"

func ParseTimeString

func ParseTimeString(timeStr string) (datetime time.Time)

func SinceDays

func SinceDays(dateString string) (int64, error)

SinceDays 获取过去的天数,dateString格式20060102

func TimeRangeDates

func TimeRangeDates(startDate string, endDate string) []string

func TimeRangeDay

func TimeRangeDay(stTime int64, endTIme int64) int

返回相差天数

func ToDate

func ToDate(ts int64, isBeijing bool) string

func ToDateTime

func ToDateTime(ts int64, isBeijing bool) string

func Today

func Today() string

func TodayLocal

func TodayLocal(timeOffsetSec int) string

NowDate

func Ts2Date

func Ts2Date(ts int64) string

func Ts2DateLocal

func Ts2DateLocal(ts int64, timeOffsetSec int) string

本地化日期 给定时间戳(以秒为单位)

func Ts2DateTime

func Ts2DateTime(ts int64) string

func Ts2DateTimeLocal

func Ts2DateTimeLocal(ts int64, timeOffsetSec int) string

本地化日期时间 给定时间戳(以秒为单位)

func Ts2DateTimeLocalFormat

func Ts2DateTimeLocalFormat(ts int64, timeOffsetSec int, format string) string

将时间对象转换为特定时区的时间

func Ts2Time

func Ts2Time(t int64) time.Time

Types

This section is empty.

Jump to

Keyboard shortcuts

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