Issue with strftime() expects parameter 2 to be long


#1

Hi there,

I have turned on strftime in my config file and now want to display the date I entered in my structure by using strftime. It works with the normal date handler but not with strftime.

The error I get:

strftime() expects parameter 2 to be long, object given

I tried using a morale date field without putting it inside a structure and have also searched all over the internet without any success. I have to admit its probably a stupid mistake on my side because strftime is running just fine on another site of mine also running Kirby.

Here is my code:

<?php if($site->urlaub() != ''): $next_holiday = $site->urlaub()->toStructure()->nth(0); ?>			
<div class="banner"><b>Bitte beachten Sie:</b> Unsere Praxis ist vom <?php echo strftime('%B %Y', $next_holiday->start()) ?> bis zum <?= $next_holiday->end('%A, %e. %B'); ?> geschlossen.</div>
<?php endif ?>

And my Blueprint:

  urlaub:
    label: Urlaub
    type: structure
    style: table
    entry:
      - start
      - end
    fields:
      start:
        label: Beginn
        type:  date
      end:
        label: Ende
        type:  date

Thanks for any help in advance!


#2

Use $next_holiday->start()->value(), otherwise, you pass a field object, not the timestamp.


#3

Now there is a new Issue:

A non well formed numeric value encountered


#4

Ah, the field is not called date, so we have to work around this:

strftime('%B %Y', $next_holiday->date(null, start()));

Should work. If not

strftime('%B %Y', strtotime($next_holiday->start()->value()));

#5

The second option worked. Thanks a lot!