timeutils

package
v0.0.0-...-5223f06 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToShanghai

func ConvertToShanghai(t time.Time) time.Time

ConvertToShanghai 将任意时区的时间转换为上海时区

func Format

func Format(t time.Time) string

Format 格式化时间为字符串 (YYYY-MM-DD HH:mm:ss)

func FormatDate

func FormatDate(t time.Time) string

FormatDate 格式化时间为日期字符串 (YYYY-MM-DD)

func Now

func Now() time.Time

Now 获取当前上海时区时间

func NowTimestamp

func NowTimestamp() int64

NowTimestamp 获取当前时间的毫秒时间戳

func Parse

func Parse(timeStr string) (time.Time, error)

Parse 解析时间字符串 (YYYY-MM-DD HH:mm:ss)

func ParseDate

func ParseDate(dateStr string) (time.Time, error)

ParseDate 解析日期字符串 (YYYY-MM-DD)

func StartOfDay

func StartOfDay(t time.Time) time.Time

StartOfDay 获取指定时间当天的 00:00:00

func StartOfDayTimestamp

func StartOfDayTimestamp(t time.Time) int64

StartOfDayTimestamp 获取指定时间当天的 00:00:00 的毫秒时间戳

func StartOfMonth

func StartOfMonth(t time.Time) time.Time

StartOfMonth 获取指定时间所在月份的1日 00:00:00

func StartOfMonthTimestamp

func StartOfMonthTimestamp(t time.Time) int64

StartOfMonthTimestamp 获取指定时间所在月份的1日 00:00:00 的毫秒时间戳

func StartOfWeek

func StartOfWeek(t time.Time) time.Time

StartOfWeek 获取指定时间所在周的周一 00:00:00 周一为一周的开始

func StartOfWeekTimestamp

func StartOfWeekTimestamp(t time.Time) int64

StartOfWeekTimestamp 获取指定时间所在周的周一 00:00:00 的毫秒时间戳

Types

This section is empty.

Jump to

Keyboard shortcuts

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