Convert string to go time.time
👉 Example 1️⃣
time, err := gotime.Parse("2016 07 25")
if err != nil {
fmt.Println(err) // handle error
}
fmt.Println(time) //2016-07-25 00:00:00 +0000 UTC
👉 Example 2️⃣
time, err := gotime.Parse("01 January 1970 00:00:00 GMT")
if err != nil {
fmt.Println(err) // handle error
}
fmt.Println(time) //1970-01-01 00:00:00 +0000 GMT
👉 Group Examples 🗂️
times := []string{"August 7, 2014", "2011-10-10T14:48:00 GMT", "2011-10-10T14:48:00", "2011-10-10T14:48:00.000+09:00", "January 1, 09 00:00:00.00 GMT"}
for _, v := range times {
fmt.Println(gotime.Parse(v))
}
🔴 OUTPUT
🧾
2014-08-07 00:00:00 +0000 UTC, nil
2011-10-10 14:48:00 +0000 GMT, nil
2011-10-10 14:48:00 +0000 UTC, nil
2011-10-10 14:48:00 +9000 UTC, nil
2009-01-01 00:00:00 +0000 GMT, nil