Precise time values in Kirby

By default, Kirby’s time fields (time, and date with time input) round time values to 5-minute intervals. This makes perfect sense for content management where exact minutes rarely matter. It also makes entering time much easier as you can press the arrow keys to go up or down 5 minutes.

Two time fields in the style of Kirby's panel under an Apple style menubar showing that the time is 09:27. One of them shows 09:25 and the other 09:27.

But if you need precise time values, you need to explicitly enable it.

How time works in Kirby

Kirby’s time fields have their step option set to 5 minutes by default. This 5-minute rounding affects:

  • Time values entered in the Panel (e.g., 9:27 becomes 9:25)
  • The current time when using default: now
  • Programmatically set values, like an updated field updated with a hook

While you immediately notice the rounding when editing the field in the panel, you might not realise right away that your default value or programmatic updates got rounded. They both follow your blueprint’s field configuration. This consistency makes a lot of sense, but it can be unexpected.

Fun fact: I only very recently found out about this when I updated kirbysites.com. I added a few websites at once and realised the order is different from what I expected. Why? Because they were all set to the same rounded time.

Setting up precise time

For precise time values, you have to set the size of the step option.

For time fields:

time:
  step:
    size: 1

For date fields with time:

date:
  time:
    step:
      size: 1

If you want to save seconds, you can additionally define the unit of the step:

time:
  step:
    size: 1
    unit: second
  display: 'HH:mm:ss'

Setting the display option is optional. The seconds would still be saved without it, but you could only see them in the content file.

Bonus tip: timezones

For reliable time handling, set your timezone in Kirby’s /index.php:

<?php

date_default_timezone_set('Europe/Berlin'); // adjust to your timezone

require 'kirby/bootstrap.php';

echo (new Kirby)->render();