package main
import (
"fmt"
"time"
)
func main() {
fmt.Println(time.Now())
fmt.Println(time.Now().Unix())
fmt.Println(time.Now().Second())
//程序耗时可以用结束时间-开始时间
fmt.Println(time.Now().UnixNano())
//里面的时间必须按照这些数值来
fmt.Println(time.Now().Format("02/1/2006 15:04"))
fmt.Println(time.Now().Format("2006-1-02 15:04"))
}
输出:
2019-01-22 13:44:16.0255278 +0800 CST m=+0.017010601
1548135856
16
1548135856100464500
22/1/2019 13:44
2019-1-22 13:44
Process finished with exit code 0
有疑问加站长微信联系(非本文作者)