Documentation
¶
Index ¶
- Constants
- func DateShrink(tm time.Time) time.Time
- func Decimal(value float64) float64
- func GetGmtimeStr() string
- func GetLocaltimeStr() string
- func GetTmShortStr(tm time.Time, format string) string
- func GetTmStr(tm time.Time, format string) string
- func GetUnixTimeShortStr(ut int64, format string) string
- func GetUnixTimeStr(ut int64, format string) string
- func GoStdRubyDate() string
- func GoStdTime() string
- func GoStdUnixDate() string
- func Greatest(arr []time.Time) time.Time
- func RandIntn(n int) int
- func ShiftZone(toLoc *time.Location, from ...time.Time) time.Time
- func StrToTime(timeStr string, template TimeTemplate) (time.Time, error)
- func ToMonday(tar ...time.Time) time.Time
- func Zone(loc *time.Location) (name string, zone int)
- type TimeSlice
- type TimeTemplate
Examples ¶
Constants ¶
View Source
const ( TT1 TimeTemplate = "2006-01-02 15:04:05" TT2 = "2006/01/02 15:04:05" TT3 = "2006-01-02" TT4 = "20060102" TT5 = "15:04:05" )
View Source
const CNM = `` /* 306-byte string literal not displayed */
View Source
const DEEPLINK = `` /* 152-byte string literal not displayed */
View Source
const EMTF = `` /* 1003-byte string literal not displayed */
View Source
const HOLLSON = `` /* 301-byte string literal not displayed */
View Source
const SYBS = `
__
_____ __/ / ___
(_-/ // / _ \(_-<
/___\_, /_.__/___/
/___/ `
Variables ¶
This section is empty.
Functions ¶
func GetGmtimeStr ¶
func GetGmtimeStr() string
func GetLocaltimeStr ¶
func GetLocaltimeStr() string
func GetUnixTimeShortStr ¶
func GetUnixTimeStr ¶
func GoStdRubyDate ¶
func GoStdRubyDate() string
func GoStdUnixDate ¶
func GoStdUnixDate() string
func ShiftZone ¶
ShiftZone 时区转换/换置(即:将from时间转换为toLoc时区的时间)
Example ¶
// 将当前时间转换为纽约时间 loc, _ := time.LoadLocation("America/New_York") _newYorkTime := ShiftZone(loc, time.Now()) _newYorkTime = ShiftZone(loc) // 默认即为Nows fmt.Println(_newYorkTime) // out: 2006-01-02 13:04:05.868597 -0500 EST
Output:
func Zone ¶
Zone 获取时区标识与时区值
常用时区名称: Asia/Shanghai: 上海 Asia/Taipei: 台北 Asia/Seoul: 首尔 Asia/Tokyo: 东京 Asia/Singapore: 新加坡 Asia/Jerusalem: 耶路撒冷 Asia/Kolkata: 加尔各答(印度) America/Los_Angeles: 洛杉矶 America/New_York: 纽约 Europe/Dublin: 都柏林 Europe/London: 伦敦 更多参考:(🔥源码才是最好的参考文档) cat /private/etc/localtime cat etc/localtime ls usr/share/zoneinfo https://www.zeitverschiebung.net/cn/city/2643743
Example ¶
loc, _ := time.LoadLocation("Asia/Shanghai") name, zone := Zone(loc) fmt.Println(name, zone) // out: CST +8
Output:
Types ¶
type TimeTemplate ¶
type TimeTemplate string
Click to show internal directories.
Click to hide internal directories.