Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Panel] Using num: date in blueprint results in error if date format is set to strftime #1882

texnixe opened this issue Jun 26, 2019 · 2 comments


Copy link

commented Jun 26, 2019

Describe the bug
If you set

num: date

for page sorting with the date handler set to strtime in the config.php file, the Panel throws an error:

Return value of Kirby\Cms\Page::createNum() must be of the type int, string returned

This does only happen with the short form, when using the query language with the correct date format for strftime, all is well.

To Reproduce
Steps to reproduce the behavior:

  1. Set date handler to strfttime
  2. Go to a note page in the Starterkit
  3. See error

Expected behavior
Don't know if this is a bug. Maybe the short form could also respect the date format. If not, we have to add a note in the docs.

Kirby Version


This comment has been minimized.

Copy link

commented Jul 16, 2019

I just ran into this issue. I tracked it down to this commit. Because the toDate method is unaware of the used date handler the method can not format the date correctly and will just return the anticipated format (e.g. Ymd or YmdHi).

For anyone in need of a quick fix you can add following plugin. It's not ideal but at least you can get it working again this way.


// plugins/datefix/index.php

Kirby::plugin('datefix/datefix', [
    'fieldMethods' => [
        'toDate' => function ($field, string $format = null, string $fallback = null) {
            if (empty($field->value) === true && $fallback === null) {
                return null;

            $time = empty($field->value) === true ? strtotime($fallback) : $field->toTimestamp();

            if ($format === null) {
                return $time;

            if (option('date.handler') === 'strftime') {
                switch ($format) {
                    case 'Ymd':
                        $format = '%Y%m%d';

                    case 'YmdHi':
                        $format = '%Y%m%d%H%M';

            return option('date.handler', 'date')($format, $time);

@distantnative distantnative self-assigned this Jul 18, 2019

@distantnative distantnative modified the milestones: 3.2.3, 3.2.4 Jul 18, 2019

@distantnative distantnative removed their assignment Aug 1, 2019

@distantnative distantnative self-assigned this Aug 8, 2019

distantnative added a commit that referenced this issue Aug 8, 2019
bastianallgeier added a commit that referenced this issue Aug 8, 2019

This comment has been minimized.

Copy link

commented Aug 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.