Documentation
¶
Index ¶
- Constants
- func DaysBetween(startDate, endDate time.Time) int
- func DaysDiff(startDate, endDate time.Time) int
- func FormatTime(t time.Time, format string) string
- func MonthsBetween(startDate, endDate time.Time) int
- func MonthsDiff(startDate, endDate time.Time) int
- func NowFormatted(format string, timezoneOffset ...int) string
- func TimeInZone(offsetHours int) time.Time
- func UnixAfterSeconds(seconds int) int64
- func YearsBetween(startDate, endDate time.Time) int
- func YearsDiff(startDate, endDate time.Time) int
Constants ¶
View Source
const ( // 定義常用的時間格式 FormatDateOnly = "2006-01-02" FormatTimeOnly = "15:04:05" FormatDateTime = "2006-01-02 15:04:05" FormatISO8601 = "2006-01-02T15:04:05Z07:00" FormatISO8601Compact = "20060102T150405Z0700" FormatRFC1123 = time.RFC1123 FormatRFC822 = time.RFC822 )
Variables ¶
This section is empty.
Functions ¶
func DaysBetween ¶
DaysBetween 函數,計算兩個日期之間的天數,返回值為正數
func MonthsBetween ¶ added in v0.6.2
MonthsBetween 函數,計算兩個日期之間的月份數,返回值為正數
func MonthsDiff ¶ added in v0.6.2
MonthsDiff 函數,計算兩個日期之間的月份數,不取絕對值
func NowFormatted ¶
NowFormatted 根據指定格式返回當前時間的字串表示,預設使用 UTC+0
func UnixAfterSeconds ¶ added in v0.6.3
UnixAfterSeconds 函數,接受一個秒數值,返回當前時間加上該秒數後的 Unix 時間戳 接受 0 和負值,如果是負值,則表示計算幾秒前的 Unix 時間戳
func YearsBetween ¶ added in v0.6.2
YearsBetween 函數,計算兩個日期之間的年數,返回值為正數
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.