Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A sample code to parse time format string.
package main
import (
"fmt"
"time"
)
func main() {
var t time.Time
t, _ = time.Parse("3:04PM", "9:01AM")
fmt.Println(t)
t, _ = time.Parse("3:04 PM", "9:02 AM")
fmt.Println(t)
t, _ = time.Parse("03:04PM", "09:03AM")
fmt.Println(t)
t, _ = time.Parse("15:04:05", "09:04:00")
fmt.Println(t)
t, _ = time.Parse("15:04:05.000", "09:05:01.123")
fmt.Println(t)
t, _ = time.Parse("15:04:05.000000", "09:06:02.012300")
fmt.Println(t)
t, _ = time.Parse("15:04:05.000000000", "09:07:03.001230000")
fmt.Println(t)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment