Skip to content

Instantly share code, notes, and snippets.

@nidhi-canopas
Created July 1, 2022 18:35
Show Gist options
  • Select an option

  • Save nidhi-canopas/ca325357087752d20e2695c8d098ed21 to your computer and use it in GitHub Desktop.

Select an option

Save nidhi-canopas/ca325357087752d20e2695c8d098ed21 to your computer and use it in GitHub Desktop.
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