我想在 Go 中获取明天早上 09:00 的日期时间对象。我目前的看法是这样的:
now := time.Now()
tomorrowMorning := time.Date(now.Year(), now.Month(), now.Day(), 9, 0, 0, 0, time.UTC).AddDate(0, 0, 1))
Run Code Online (Sandbox Code Playgroud)
不过,这似乎有点冗长。没有更简单的方法来做到这一点吗?
直接在天上加 1 来简化。
now := time.Now()
tomorrowMorning := time.Date(now.Year(), now.Month(), now.Day() + 1, 9, 0, 0, 0, time.UTC)
Run Code Online (Sandbox Code Playgroud)
该time.Date功能使一天正常化。
| 归档时间: |
|
| 查看次数: |
77 次 |
| 最近记录: |