1

I has a special time string like this: February 24, 2017 , 1:44 pm and want to translate it to a golang time.Time object, does anyone know how to do this work. I have tried to using time.Parse(), but always got errors.

Thanks.

1

2 Answers 2

2

Use the format string January 2, 2006 , 3:04 pm to parse that kind of string.

Example: https://play.golang.org/p/4HgRekLr-7

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help.
0

Read https://golang.org/pkg/time/#pkg-constants to know how to define your own formats or use predefined formates.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.