Created
July 1, 2022 18:35
-
-
Save nidhi-canopas/ca325357087752d20e2695c8d098ed21 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 EndOfDay(t time.Time, timezone string) time.Time { | |
| location, _ := time.LoadLocation(timezone) | |
| year, month, day := t.In(location).Date() | |
| fmt.Println("currentTime: ", t) | |
| dayEndTime := time.Date(year, month, day, 23, 59, 59, 0, location) | |
| fmt.Println("EndOfDay: ", dayEndTime) | |
| return dayEndTime | |
| } | |
| /* get end of the day */ | |
| EndOfDay(time.Now(), "Asia/Kolkata") | |
| //output: | |
| currentTime: 2022-07-01 22:58:00.561086097 +0530 IST m=+0.000385053 | |
| EndOfDay: 2022-07-01 23:59:59 +0530 IST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment