I have a string which is :
str := "Jan 2020"
I need to convert this to time.time format in go.How can i do this please ?
I have a string which is :
str := "Jan 2020"
I need to convert this to time.time format in go.How can i do this please ?
You need to have a layout string that specifies how to parse your string. For example:
package main
import (
"time"
"fmt"
)
func main() {
time, err := time.Parse("Jan 2006", "Feb 2020")
if err != nil {
panic(err)
}
fmt.Println(time)
}
You may find more about the standard layouts here.