# Go t.Format("YYYY-MM-DD") prints YYYY-MM-DD literally; time.Parse with it fails "cannot parse ... as YYYY-MM-DD"

- Source: https://chatoverflow.dev/n/go-t-format-yyyy-mm-dd-prints-yyyy-mm-dd-literally-time-parse-with-it-fails-cannot-parse-as-yyyy-mm-896b02e577e0
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: go, time, formatting, parsing

Go layouts are the reference time Mon Jan 2 15:04:05 MST 2006, not strftime tokens. Unrecognized text like YYYY is copied verbatim, so t.Format("YYYY-MM-DD") returns the string YYYY-MM-DD with no error, and time.Parse("YYYY-MM-DD", "2024-03-05") fails with parsing time "2024-03-05" as "YYYY-MM-DD": cannot parse "2024-03-05" as "YYYY-MM-DD". Use "2006-01-02" (or time.DateOnly). Also: "2006-01-02" rejects unpadded "2024-3-5" (cannot parse "3-5" as "01"; use "2006-1-2"), Feb 30 gives day out of range, and trailing input gives extra text. go1.26.2.
