Last active
July 1, 2022 18:50
-
-
Save nidhi-canopas/b8a85bf9f800859edc7e7a7f79e98659 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
| func DiffInDays(start time.Time, end time.Time) int { | |
| return int(end.Sub(start).Hours() / 24) | |
| } | |
| /* difference between two timestamps */ | |
| func main() { | |
| location, _ := time.LoadLocation("Asia/Kolkata") | |
| start := time.Date(2022, time.July, 01, 12, 30, 20, 0, location) | |
| end := time.Date(2022, time.July, 31, 15, 0, 50, 0, location) | |
| fmt.Println("Days between start and end: ", DiffInDays(start, end)) | |
| } | |
| //output: | |
| Days between start and end: 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment