This is maybe a stupid question to ask but I can’t seem to find how to convert date in string format to date time format. Many thanks!
s := "12-25-2012"
var t time.Time
t = s.Time() ???
I would like t to contain the value of s.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need time.Parse() and a format string that matches your supplied date string.
Here’s an example using your date format.
http://play.golang.org/p/YAeAJ3CNqO
You can read more about making custom format strings in this post.