time
1 常量
const (
Layout = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
ANSIC = "Mon Jan _2 15:04:05 2006"
UnixDate = "Mon Jan _2 15:04:05 MST 2006"
RubyDate = "Mon Jan 02 15:04:05 -0700 2006"
RFC822 = "02 Jan 06 15:04 MST"
RFC822Z = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone
RFC850 = "Monday, 02-Jan-06 15:04:05 MST"
RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone
RFC3339 = "2006-01-02T15:04:05Z07:00"
RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
Kitchen = "3:04PM"
// Handy time stamps.
Stamp = "Jan _2 15:04:05"
StampMilli = "Jan _2 15:04:05.000"
StampMicro = "Jan _2 15:04:05.000000"
StampNano = "Jan _2 15:04:05.000000000"
DateTime = "2006-01-02 15:04:05"
DateOnly = "2006-01-02"
TimeOnly = "15:04:05"
)2 函数
2.1 func After(d Duration) <-chan Time
2.2 func Sleep(d Duration)
2.3 func Tick(d Duration) <-chan Time
3 类型
3.1 Duration
3.1.1 func ParseDuration(s string) (Duration, error)
3.1.2 func Since(t Time) Duration
3.1.3 func Until(t Time) Duration
3.1.4 func (d Duration) Abs() Duration
3.1.5 单位转换方法集
方法名
返回类型
说明
3.1.6 func (d Duration) Round(m Duration) Duration
3.1.7 func (d Duration) Truncate(m Duration) Duration
3.1.8 func (d Duration) String() string
3.2 Location类型
3.2.1 func FixedZone(name string, offset int) *Location
3.2.2 func LoadLocation(name string) (*Location, error)
3.2.3 func LoadLocationFromTZData(name string, data []byte) (*Location, error)
3.2.4 func (l *Location) String() string
3.3 Month类型
3.3.1 func (m Month) String() string
3.4 Weekday类型
3.4.1 func (d Weekday) String() string
3.5 Ticker类型
3.5.1 func NewTicker(d Duration) *Ticker
3.5.2 func (t *Ticker) Reset(d Duration)
3.5.3 func (t *Ticker) Stop()
3.6 Timer类型
3.6.1 func NewTimer(d Duration) *Timer
3.6.2 func AfterFunc(d Duration, f func()) *Timer
3.6.3 func (t *Timer) Reset(d Duration) bool
3.6.4 func (t *Timer) Stop() bool
3.7 Time类型
3.7.1 func Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time
3.7.2 func Now() Time
3.7.3 func Parse(layout, value string) (Time, error)
3.7.4 func ParseInLocation(layout, value string, loc *Location) (Time, error)
3.7.5 func Unix(sec int64, nsec int64) Time
3.7.6 func UnixMicro(usec int64) Time
3.7.7 func UnixMilli(msec int64) Time
3.7.8 func (t Time) Add(d Duration) Time
3.7.9 func (t Time) AddDate(years int, months int, days int) Time
3.7.10 func (t Time) Sub(u Time) Duration
3.7.11 func (t Time) Round(d Duration) Time
3.7.12 func (t Time) Truncate(d Duration) Time
3.7.13 func (t Time) After(u Time) bool
3.7.14 func (t Time) Before(u Time) bool
3.7.15 func (t Time) Equal(u Time) bool
3.7.16 func (t Time) Compare(u Time) int
3.7.17 func (t Time) IsZero() bool
3.7.18 func (t Time) IsDST() bool
3.7.19 func (t Time) Date() (year int, month Month, day int)
3.7.20 func (t Time) Clock() (hour, min, sec int)
3.7.21 各时间分量独立获取
方法
返回值
范围
示例
3.7.22 func (t Time) ISOWeek() (year, week int)
3.7.23 func (t Time) YearDay() int
3.7.24 func (t Time) Zone() (name string, offset int)
3.7.25 func (t Time) ZoneBounds() (start, end Time)
3.7.26 func (t Time) Location() *Location
3.7.27 func (t Time) In(loc *Location) Time
3.7.28 func (t Time) Local() Time
3.7.29 func (t Time) UTC() Time
3.7.30 func (t Time) Format(layout string) string
3.7.31 func (t Time) AppendFormat(b []byte, layout string) []byte
3.7.32 func (t Time) String() string
3.7.33 func (t Time) GoString() string
3.7.34 func (t Time) MarshalJSON() ([]byte, error)
3.7.35 func (t *Time) UnmarshalJSON(data []byte) error
3.7.36 func (t Time) MarshalText() ([]byte, error)
3.7.37 func (t *Time) UnmarshalText(data []byte) error
最后更新于