timezone

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TimeConvertTimeZone

func TimeConvertTimeZone(t time.Time, tz string) (timeInTZ time.Time, err error)

将时间t转换为某时区的时间。 ! 注意:此过程是强行设置,而非转换。如转换前后的时区不同,则时间字面上也发生变化。

func TimeSetTimezone

func TimeSetTimezone(t time.Time, tz string) (timeInTZ time.Time, err error)

将某个时间t 的字面时间设置为某时区的时间。适用于前端传入UTC时间后,在后端设置为用户自己时区的时间。 ! 注意:此过程是强行设置,而非转换。字面上时间不变化,仅时区发生了变化。 t: 时间,可能含任意时区信息。本过程将忽略t的时区,强制将t设置为时区tz。 tz: 合法的时区字符串,如tz == "",则设置为UTC时区 例如,t 为 2021-04-28 00:00:00 -0700 PDT tz为:Asia/Shanghai,则 timeInTZ 为2021-04-28 00:00:00 +0800 PDT

Types

This section is empty.

Jump to

Keyboard shortcuts

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