Golang获取时间戳

323 阅读1分钟

获取当天0时的时间戳

package main

import (
    "fmt"
    "time"
)

func main() {
    t := time.Now()
    newTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
    fmt.Println(newTime.Unix())
}