Skip to content

Instantly share code, notes, and snippets.

@nidhi-canopas
Last active February 27, 2022 20:12
Show Gist options
  • Save nidhi-canopas/46ce3ad708c6cdd4cede32e215cb3713 to your computer and use it in GitHub Desktop.
Save nidhi-canopas/46ce3ad708c6cdd4cede32e215cb3713 to your computer and use it in GitHub Desktop.
import (
"time"
"fmt"
)
func main() {
currentTime := time.Now()
// Time after 18 hours of currentTime
futureTime := time.Now().Add(time.Hour * 18)
// Time after 10 hours of currentTime
intermediateTime := time.Now().Add(time.Hour * 10)
if intermediateTime.After(currentTime) && intermediateTime.Before(futureTime) {
fmt.Println("intermediateTime is between currentTime and futureTime")
} else {
fmt.Println("intermediateTime is not inbetween currentTime and futureTime")
}
}
output:
intermediateTime is between currentTime and futureTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment