MikeZhang
MikeZhang

Reputation: 337

How to parse datetime in golang in special format?

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.

Upvotes: 1

Views: 1201

Answers (2)

Kumar Sukhani
Kumar Sukhani

Reputation: 407

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

Upvotes: 0

alanfran
alanfran

Reputation: 180

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

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

Upvotes: 2

Related Questions