A. Import packages
import "time"
II. Time object is converted into
- Get the current time:. Time Now ()
- Custom time:. Time Date (year int, month Month, day, hour, min, sec, nsec int, loc * Location)
Method three .Time object
Day of week
- Date (): Returns the date time information
返回值int类型
- Year (): Returns the Year
返回值int类型
- Month (): Returns the month
返回值Month类型
- Day (): Returns the day
返回值int类型
- YearDay (): corresponding day of the year
返回值int类型
Annual, week number range
- ISOWeek (): Returns the annual, week number range
int类型
Minutes and seconds
Clock (): return every minute
返回值int类型
Hour (): returns
返回值int类型
Minute (): Returns the minutes
返回值int类型
Second (): Returns the seconds
返回值int类型
Nanosecond (): Returns the nanosecond
返回值int类型
Timestamp
- Unix (): timestamp
返回值 int64
- UnixNano (): timestamp (ns)
返回值 int64
Time zone
- Location (): time zone
返回值 *Location
- Zone (): time zone offset
返回值string+int
Four time series and the sequence of the back and compared to the calculated
referencehttps://www.jianshu.com/p/9d5636d34f17
Column and returning sequence of
func (t Time) MarshalBinary() ([]byte, error) {}
// Time serialization
func (t Time) UnmarshalBinary(data []byte) error {}
// deserialize
func (t Time) MarshalJSON() ([]byte, error) {}
// Time serialization
func (t Time) MarshalText() ([]byte, error) {}
// Time serialization
func (t Time) GobEncode() ([]byte, error) {}
// Time serialization
func (t Time) GobDecode() ([]byte, error) {}
// Time serialization
Compared to the calculated
func (t Time) IsZero() bool {}
// if time is zero
func (t Time) After(u Time) bool {}
// before time u
func (t Time) Before(u Time) bool {}
// time after u
func (t Time) Equal(u Time) bool {}
// the same time with u
func (t Time) Add(d Duration) Time {}
// returns the point in time t + d
func (t Time) Sub(u Time) Duration {}
// returns tu
func (t Time) AddDate(years int, months int, days int) Time {}
Increase the return given year, month and day