$page->modified not workign when date.handler is set to strftime

Hi,

curious whether I am doing something wrong or whether the following is a bug. To me it seems that $page->modified() is not working as expected when date.handler is set to strftime.

It just returns the format string in my setting.

To reproduce:

  1. Set date.handler to strtime in config (‘date.handler’ => ‘strftime’,)
  2. Access $page->modified() or a part with a modified datetime in the panel.
  3. See that the date is not displayed, rather just the format string.

Versions: had the issue with 3.2.3 and still have it with 3.2.5.

To test:

add the following to the template or HTML head snippet:

<!--
contentfiles: <?php print_r($page->contentFiles()); ?>
modified: <?= $page->modified(); ?>
modified-formatted: <?= $page->modified('Y-m-d'); ?>
-->

With date.handler set to strftime the following output is generated:

<!-- 
contentfiles: Array
(
    [0] => /var/www/vhosts/hosting100583.af9aa.netcup.net/httpdocs/fingolex/fl-prod/content/4_blog/0_it-sicherheit-im-internet-der-dinge/article.de.txt
    [1] => /var/www/vhosts/hosting100583.af9aa.netcup.net/httpdocs/fingolex/fl-prod/content/4_blog/0_it-sicherheit-im-internet-der-dinge/article.en.txt
)
modified: 1569493348modified-formatted: Y-m-d-->

Without date.handler setting, the following output is generated

<!-- 
contentfiles: Array
(
    [0] => /var/www/vhosts/hosting100583.af9aa.netcup.net/httpdocs/fingolex/fl-prod/content/4_blog/0_it-sicherheit-im-internet-der-dinge/article.de.txt
    [1] => /var/www/vhosts/hosting100583.af9aa.netcup.net/httpdocs/fingolex/fl-prod/content/4_blog/0_it-sicherheit-im-internet-der-dinge/article.en.txt
)
modified: 1569493348modified-formatted: 2019-09-26-->

blueprint use

Similarly, my blog blueprint, which has the following block:

pages:
  template: article
  sort: datetime desc
  num:
    mode: datetime
    field: datetime
    format: ymdH
    display: Y-m-d-H

will have the Y-m-d-H pattern show up in panel. When I remove the date.handler in config, the panel indeed shows a time.

Best, Baltasar

If you use the strftime date handler, you have to use the correct format syntax for strftime:

https://www.php.net/manual/de/function.strftime.php

Thanks, how blind could I be…
That has evidently been the problem.

Do you have a hint on how to fix the blueprint?

pages:
  template: article
  sort: datetime desc
  num:
    mode: datetime
    field: datetime
    format: YmdH
    display: Y-m-d-H

I think you can not change the display format, there is no display option. The format option defines how the value is saved. I have to look into this.

As regard the Panel display, there is a plugin that allows you to change how the date is displayed: https://github.com/mullema/k3-date-format. Haven’t tested.

Thanks for the insights. I copied that part of blueprint from somewhere, can’t remember where. The display is not important – sorting works, the rest is just a nice view or not (but as it’s only admins, it’s really not a big issue). Not worth investigating much for me.

That blueprint snippet looks a bit strange to me, anyway. What are you trying to do there? Is that supposed to be a section?

To be honest, I did not really look into it – and I only partially understand the blueprint topic at the moment. I copied from a blog instruction. The only thing important to me is that the sorting is working (which is probably what the sort line does). Anyway, the sorting (and thereby everything that is really needed) works and I will see when I will have a closer look at the topics. My implementation certainly has more issues which I will slowly try to fix.

The full blueprint looks like this

$ cat site/blueprints/pages/blog.yml
title: Blog
icon: 📚

pages:
  template: article
  sort: datetime desc
  num:
    mode: datetime
    field: datetime
    format: YmdH
    display: %Y-%m-%d-%H

columns:
  left:
    width: 1/2
    sections:
      drafts:
        extends: sections/articles
        headline:
            en: Drafts
            de: Entwürfe
        status: draft
        create: article

      unlisted:
        extends: sections/articles
        headline:
            en: In Review
            de: In Redaktion
        status: unlisted

      listed:
        extends: sections/articles
        headline:
           en: Published
           de: Veröffentlicht
        status: listed

  right:
    width: 1/2
    fields:
      text:
        type: textarea
        label:
           en: Text displayed on top
           de: Vorangestellter Text