Raggaer
Raggaer

Reputation: 3318

Go parsing time string

I currently have the following date string

May 21 2016, 21:47:08 CEST

So I want to parse it. I tried the following

time, err := time.Parse("Jan 2 2006, 15:04:05 MST", date)

But I am getting the following error

parsing time "May 21 2016, 21:47:08 CEST" as "Jan 2 2006, 15:04:05 CEST": cannot parse " 21 2016, 21:47:08 CEST" as " "

I think I have checked that all the values are correct on the layout.

Upvotes: 1

Views: 123

Answers (1)

John Smith
John Smith

Reputation: 2341

You can compare the two strings (the one that won't work, and where you type the "same" string in manually) and you can see there's a difference. The string that doesn't work uses A0 (hex) non-breaking space, while the one that works uses the regular space 20 (hex).

You can see it in the playground: https://play.golang.org/p/6UIEKg9hs0

Upvotes: 4

Related Questions