Page Creation date

Hello
I can’t manage to display the creation date of a page in a table. What am I doing wrong?

headline: Inhalte
type: pages
template:
  - layoutcomposer
  - blog
create:
  - layoutcomposer
search: true
empty: Keine Inhaltselemente vorhanden!
sortBy: date desc title asc
layout: table
columns:
  date:
    label: 'erstellt am...'
    value: '{{ page.date }}'
    width: 1/6

Do the pages have a date field? Maybe you named it different…

No, the page does not have a separate date field.
Isn’t it so that when the page (file) is created, it gets a creation date?

Well, in the file system, yes, everything that gets created or modified gets a date. But you are calling $page->date() which refers to either a default page class method or to a custom model method or to something present in your content. Since there is no default page method of that name, and if you don’t have a date field, nothing will be shown.

So to reliably get when a page was created, you would have to create a disabled date field with the default set to now.

Okay… that makes sense. :see_no_evil:

Tankyou

I have now created a field:

published:
  label: 'Erstellt am:'
   type: date
  display: DD.MM.YYYY
  default: now
  disabled: true

…and read this out:

...
layout: table
columns:
  date:
    label: 'erstellt am...'
    value: '{{ page.published }}'
    width: 1/6

It works fine:

But if I want to change the date format…

layout: table
columns:
  ...
  date:
    label: 'erstellt am...'
    value: '{{ page.published.toDate('d.m.Y') }}'
    width: 1/6

…the following happens:

What am I doing wrong?

You are using single quotes for both, change one of the pairs

I tried this:

value: "{{ page.published.toDate('d.m.Y') }}"

With the same result as in the screenshot before.
I tried it the other way round, with the quotes.

Hm, have you set the date handler to something different from the default in your config?

Yes, I have the following in the Config:

'date.handler'  => 'strftime',

If I remove the entry, then it also works with the formatting of the date.

Unfortunately, I can no longer say why I made the change in config.php.
Can you give me an estimate of what the collective damage could be if I remove the entry completely?

Each date handler has its own syntax for formatting dates. The format you used in the blueprint works with the default handler, but not with strftime or intl.

strftime is deprecated and shouldn’t be used anymore.

If you need non-English dates, use intl, and then the compatible format strings, see link in documentation.

I have now changed the following in config.php:

'date.handler' => 'intl',

And changed the following on the site bluprint:

date:
    label: 'erstellt am...'
    value: "{{ page.published.toDate('dd.mm.yy') }}"
    width: 1/6

And the column remains empty again:

If I remove ‘date.handler’ completely, then it works if I

value: "{{ page.published.toDate('d.m.y') }}"

change accordingly:

Maybe too late, but if you like, you could check out this plugin which does basically the same:

Thank you Adspectus for the tip. I’m trying to solve the whole thing with Kirby’s on-board resources. Plugins always mean a certain dependency and I try to avoid that. Nevertheless many thanks.