文档

获取时间对象

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
}

YYYY-mm-dd HH-mm-ss

获取当前时间戳

10位的时间戳

package main

import (
	"fmt"
	"time"
)

func main() {
	now := time.Now().Unix()
	// 1676518359
	fmt.Println("now", now)
}