I have MySQL datetime in my table in the MySQL standard format like
"2018-09-19 18:26:32.000000"
and when I try converting it ti golang time using time.parse()
function, I get the error that
parsing time "2018-09-19 18:26:32.000000": month out of range
I tried searching online and the format seems to be allowed and commonly used by many to successfully parse.
Can anyone help me with what I am missing? Below is the code snippet that I am using.
import (
"fmt"
"time"
)
layout := "2018-09-19 18:26:32.000000"
fmt.Println(val)
// prints 2018-09-19 18:26:32.000000
t, err := time.Parse(layout, val)
fmt.Println(fmt.Println(t.Unix()))
// prints -62135596800
fmt.Println(err)
// prints parsing time "2018-09-19 18:26:32.000000": month out of range