go 获取时间零点时间戳

1.某天的零点

the_time, err := time.ParseInLocation("2006-01-02", "2020-01-10", time.Local)
if err == nil {
   unix_time := the_time.Unix()
   fmt.Println(unix_time) //1578585600
}

2.获取当天的零点

	timeStr := time.Now().Format("2006-01-02")
	fmt.Println("timeStr:", timeStr)
	t, _ := time.ParseInLocation("2006-01-02", timeStr, time.Local)
	timeNumber := t.Unix()
	fmt.Println("timeNumber:", timeNumber)  //1578844800

你可能感兴趣的:(go,应用)