Get the posts earlier than a date

Hi everyone,
I need to show posts at the end of the post view. Those posts that we can call “related posts” MUST BE older than the actual post that the user is reading.

I wanted to implement this via where, but how I can tell the where to filter all the posts via time?
I was thinking something like where $post is less or equal than the $date ($post are all the pages of website, and $date is the actual publication date of the post).

Something related has been discussed here:

Have you considered using the built-in Related Content capability? With the default configuration this will not include pages newer than the current page.

includeNewer = false

If you would prefer to somehow roll your own, this is how to display pages in the current section that are older than the current page.


  This post is dated: {{ .Date.Format "2006-01-02 15:04:05" }}<br><br>

  Posts created before this date include:<br>
  {{ $p := where .Site.RegularPages "Type" .Section }}
  {{ $p := where $p ".Date.Unix" "lt" .Date.Unix }}
  {{ range $p }}
    {{ .Title }} - {{ .Date.Format "2006-01-02 15:04:05" }}<br>
  {{ end }}