Last active
February 27, 2022 20:12
-
-
Save nidhi-canopas/46ce3ad708c6cdd4cede32e215cb3713 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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