The Go Blog

package time

bantana
28 July 2015

introduction

time.now

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Println("package time...")
    now := time.Now()
    fmt.Println(now)
    fmt.Println(now.Year())
    fmt.Println(now.Month())
    fmt.Printf("%T %v\n", now.Month(), now.Month())
    fmt.Printf("%T %v\n", int(now.Month()), int(now.Month()))
    fmt.Println(now.Day())
    fmt.Println(now.Hour())
    fmt.Printf("%T: %v\n", now.Unix(), now.Unix())

    _, month, day := now.Date()
    fmt.Println(month, day)
}

// package time...
// 2015-07-29 23:34:13.950309736 +0800 CST
// 2015
// July
// time.Month July
// int 7
// 29
// 23
// int64: 1438184053
// July 29

Related articles