Display a time on a page

I like to display the time of the timepickwer in a template, but I can’t find a hint in the docs how to do that.

I tried this:

 <time class="date"><?= $page->date()->toDate('%d.%m.%Y') ?> | <?= $page->Time() ?></time>

But it doesn’t give me the time. I tried several variations, but no.

In the docs I can only finde the explanation for the blueprint, but it has no example for the template.

Oh, what, I am about to get it. Don’t tell me yet. Its a question of the right variable, right?

Let me give you a hint:


And I assume you are using the datepicker with a the time, not a separate time picker, right? So…

View Solution
<time class="date"><?= $page->date()->toDate('%d.%m.%Y | %H:%M') ?></time>

Oh, a details Field in a comment? Magic!

Anyway, first I tried the date field with time and tried to guess the time values, then I used the time picker and guessed that

<?= $page->time() ?>

And it works - with the right variable on several templates.



How could I not guess that?!


Thank you!!

PS: In my config I had set

    'date.handler' => 'strftime',

Maybe I should have use the blur spoiler instead :wink: Anyway, you are welcome.

Fuuunn!! :-)))))

BTW, if you want to format your time:

echo $page->time()->toDate('H:i T'); // => 02:15 UTC

(or the equivalent strftime values: echo $page->time()->toDate('%H:%M %Z'))

What is

('H:i T')

Hours in Time? Whats “i”?

H: hours
i: minutes
T: timezone