Parse time

suggest change

Parsing is the reverse of formatting:

	s := "2017-04-09 03:38:45.000 UTC"
	t, err := time.Parse("2006-01-02 15:04:05.000 MST", s)
	if err != nil {
		log.Fatalf("time.Parse() failed with '%s'\n", err)
	}
	fmt.Printf("year: %d, month: %d, day: %d\n", t.Year(), t.Month(), t.Day())
year: 2017, month: 4, day: 9

The parsing layout uses the same reference time as formatting. In 2006-01-02, 01 is the month and 02 is the day.

What if you prefer strftime style of parsing time? That’s available too.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents