Last active
August 10, 2018 22:07
-
-
Save srph/6a8c3fa59213931b2ffc3dd59a0c88a3 to your computer and use it in GitHub Desktop.
Go: Get today time.Time instance with given hour and minutes
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
package main | |
import ( | |
"time" | |
) | |
func nowWithGivenTime(hour int, minutes int) (time.Time, error) { | |
today := time.Now() | |
l, err := time.LoadLocation("Local") | |
if err != nil { | |
return nil, err | |
} | |
return time.Date(today.Year(), today.Month(), today.Day(), hour, minutes, 0, 0, l), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment