Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "time"
- )
- func main() {
- interval := 4 * time.Hour
- now := time.Now().UTC()
- offset := now.UnixNano() % int64(interval)
- pastTime := now.Add(-time.Duration(offset))
- futureTime := now.Add(interval - time.Duration(offset))
- fmt.Println(pastTime)
- fmt.Println(futureTime)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement