1.time.Time类型,用来表示时间
2.获取当前时间
now := time.Now()
now := time.Now().Day()
now := time.Now().Minute()
now := time.Now().Month()
now := time.Now().Year()
3.格式化
fmt.Printf("%02d%02d%02d %02d:%02d:%02d",now.Year()....)
now := time.Now() //获取当前时间
fmt.Printf(now.Format("02/1/2006 15:04"))
fmt.Printf(now.Format("2006/1/02 15:04"))
fmt.Printf(now.Format("2006/1/02"))
//格式化时要转化为的时间格式必须写 2006/1/02 15:04 即go的诞生时间
4.获取纳秒
time.Duration
5.一些常量
const ( Nanosecond Duration =1 Microsecond = 1000 * Nanosecond Millisecond = 1000*Microsecond Second = 1000* Millisecond Minute = 60*Second Hour = 60* Minute )
6.获取时间戳
time.Now().Unix() //获取当前时间戳 time.Now().UnixNano() //获取当前时间戳纳秒