go:time:go_time_layout_reference
Table of Contents
Go time layout reference
Rule
Go uses a special reference date/time to define layouts for `time.Format()` and `time.Parse()`.
Reference time:
- `Mon Jan 2 15:04:05 MST 2006`
Common numeric form:
- `2006-01-02 15:04:05`
Meaning of digits
- `2006` = year
- `01` = month
- `02` = day
- `15` = hour (24h)
- `04` = minute
- `05` = second
Example
layout := "2006-01-02 15:04:05" t, _ := time.Parse(layout, "2026-01-09 10:30:00") fmt.Println(t.Format(layout))
Notes
- `YYYY-MM-DD` is NOT valid in Go layouts.
- Use `time.RFC3339` for APIs when possible.
Hard words (English)
- reference /ˈrefərens/: tham chiếu
- layout /ˈleɪaʊt/: mẫu định dạng
- represent /ˌreprɪˈzent/: đại diện
- placeholder /ˈpleɪsˌhoʊldər/: ký hiệu thay thế
go/time/go_time_layout_reference.txt · Last modified: by phong2018
