为了获得今天时间对象的本地开始,我提取YMD并重建新日期.这看起来像一个kludge.我是否会错过其他一些标准库函数?
代码也可以在http://play.golang.org/p/OSRl0nxyB7上运行:
func Bod(t time.Time) time.Time {
year, month, day := t.Date()
return time.Date(year, month, day, 0, 0, 0, 0, t.Location())
}
func main() {
fmt.Println(Bod(time.Now()))
}
Run Code Online (Sandbox Code Playgroud)