@jmooring thanks so your approach relies on the now.Day
method. Interesting. This did not work for my needs, but reminded me of the .AddDate
method which feels a bit counter-intuitive but hey, it works powerfully
In my case I needed to feed .AddDate
a specific arbitrary date values in the past such as 2022-02-01
so here is what works for my use case:
{{ $d := "2022-02-01" | time.AsTime }}
{{ $d.AddDate 0 1 -1 | time.Format "2006-01-02" }}
// 2022-02-28
{{ $d.AddDate 0 1 -1 | time.Format "02" }}
// 28
I realize the way I worded this topic @jmooring answer is correct and thus is the Solution.