Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't parse date with golang, unexpected "e" string

I’m trying to parse a date string June, 24 2022,

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Println(time.Parse("Jan, 02 2006", "June, 24 2022"))
}

And it fails:

0001-01-01 00:00:00 +0000 UTC parsing time "June, 24 2022" as "Jan, 02 2006": cannot parse "e, 24 2022" as ", "

Looks like golang mistakenly took "June" as "Jun", how can I fix it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you’re using full month names, then your format string needs "January", not "Jan".

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading