文档
- https://go-zh.org/pkg/time/
package main
import (
"fmt"
"time"
)
// 24小时制 https://www.zhihu.com/question/366830553
const LAYOUT = "2006-01-02 15:04:05"
func main() {
// 获取当前日期
now := time.Now()
fmt.Printf(now.Format(LAYOUT))
// 2022-08-31 09:48:40
}
需要注意的是:Golang的格式化字符串,并不是YYYY-mm-dd HH-mm-ss
, 而是一个独特的日期