Created
July 17, 2022 08:56
-
-
Save ealebed/2b10df7b4e32653bd6ca48e0b8f6886f to your computer and use it in GitHub Desktop.
Count time to date/time in future
This file contains 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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
loc, _ := time.LoadLocation("Europe/Kiev") | |
now := time.Now().In(loc) | |
futureDate := time.Date(2022, time.August, 5, 13, 41, 0, 0, loc) | |
fmt.Println("\nCurrent time:", now) | |
fmt.Printf("======================================================\n") | |
fmt.Println("Meeting day time:", futureDate) | |
fmt.Printf("======================================================\n") | |
diff := futureDate.Sub(now) | |
days := int(diff.Hours() / 24) | |
fmt.Printf("Time to hugs in days: %d days\n", days) | |
hrs := int(diff.Hours()) | |
fmt.Printf("Time to hugs in hours: %d Hours\n", hrs) | |
mins := int(diff.Minutes()) | |
fmt.Printf("Time to hugs in minutes: %d Minutes\n", mins) | |
second := int(diff.Seconds()) | |
fmt.Printf("Time to hugs in seconds: %d Seconds\n", second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment