Select whole month not only until 0 o'clock

Hello all,

I have the following code in which I limit a list of entries to one month:

but unfortunately the 31 of a month are not listed:
https://rollenspiel.monster/donate/#monatslog

Apparently this is more of a date issue, isn’t there an easier way to select a whole month. The following was just suggested to me:

The following would have occurred to me now, for the table it should be enough if he looks one day into the future.
{{ $endDate := (now.AddDate 0 0 1).Format “2006-01-02” }}

I would just compare yyyy-mm.

data/foo.json

[
  {
    "name": "a",
    "date": "2023-04-30"
  },
  {
    "name": "b",
    "date": "2023-05-01"
  },
  {
    "name": "c",
    "date": "2023-05-31"
  },
  {
    "name": "d",
    "date": "2023-06-01"
  }
]

template

{{ range site.Data.foo }}
  {{ if eq (.date | time.Format "2006-01") (now.Format "2006-01") }}
    {{ .name }}
  {{ end }}
{{ end }}

result (running the code on 2023-05-nn)

b c

Ok that’s cool, I didn’t get that idea.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.