This is my code:
t, _ := time.Parse("12/1/2015 12:00:00", "12/8/2015 12:00:00")
fmt.Println(t)
This is the result: 0001-01-01 00:00:00 +0000 UTC
How to get correct the date string?
Thanks!
You need to use the reference timestamp 2006-01-02 15:04:05
for the layout parameter (playground):
t, _ := time.Parse("1/2/2006 15:04:05", "12/8/2015 12:00:00")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With