sizeof.blog

2006-01-02 15:04:05

As a .NET developer, this felt... weird. So I'm saving it here as a note.

I had to use time formatting, and I had to do it like that:

time.Now().Format("2006-01-02 15:04:05")

Go uses this unique approach to time formatting. So instead of using placeholders like YYYY MM Go uses a specific reference date:

2006-01-02 15:04:05
Mon Jan 2 15:04:05 -0700 MST 2006
0   1   2  3  4  5              6

Can we use some other date?

NO!

More details:

https://pkg.go.dev/time#example-Time.Format https://stackoverflow.com/a/52966197/5405449

Cheers 👯‍♀️