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

Time:06-28

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?

CodePudding user response:

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

  • Related