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.

MikeZhang
  • 327
  • 2
  • 10
  • Here is a link to a stack that shows you a list of formatters http://stackoverflow.com/questions/20234104/how-to-format-current-time-using-a-yyyymmddhhmmss-format – reticentroot Feb 26 '17 at 17:41

2 Answers2

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

alanfran
  • 180
  • 1
  • 7
0

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

Kumar Sukhani
  • 377
  • 2
  • 8