Go语言学习之time包(获取当前时间戳等)(the way to go)

冯鸿哲
2023-12-01

生命不止,继续 go go go !!!

每种语言都需要对时间进行处理,golang当然也不例外,go语言为我们提供了time package用于各种时间的转换,处理。

Package time provides functionality for measuring and displaying time.

获取当前时间

func Now

func Now() Time

Now returns the current local time.

func (Time) UTC

func (t Time) UTC() Time

UTC returns t with the location set to UTC.

func (Time) Unix

func (t Time) Unix() int64

Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.

 类似资料: