Created
August 13, 2017 17:47
-
-
Save franklinsales/b336b46eca4ebbd9f4243cb37987a1e5 to your computer and use it in GitHub Desktop.
Convert string with a time to a golang time type.
This file contains 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 ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
timeFormat := "15:04:05" | |
myTimeString := "23:03:01" | |
timeParsed, _ := time.Parse(timeFormat, myTimeString) | |
fmt.Printf("The type of timeParsed is: %T \n", timeParsed.Format(timeFormat)) | |
fmt.Printf("The value of timeParsed is: %v \n", timeParsed.Format(timeFormat)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment