Last active
July 1, 2022 18:40
-
-
Save nidhi-canopas/75532ba3411e2fc9314df421ac416f42 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 StartOfDay(t time.Time, timezone string) time.Time { | |
| location, _ := time.LoadLocation(timezone) | |
| year, month, day := t.In(location).Date() | |
| fmt.Println("currentTime: ", t) | |
| dayStartTime := time.Date(year, month, day, 0, 0, 0, 0, location) | |
| fmt.Println("StartOfDay: ", dayStartTime) | |
| return dayStartTime | |
| } | |
| /* get start of the day for given time */ | |
| StartOfDay(time.Now(), "Asia/Kolkata") | |
| //output: | |
| currentTime: 2022-07-01 22:47:16.791297534 +0530 IST m=+0.000346856 | |
| StartOfDay: 2022-07-01 00:00:00 +0530 IST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment