Golang获取零点时间戳最佳方法
代码示例:
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())
}
代码示例:
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())
}