# Time

A time picker field

****

- Read more: <https://getkirby.com/docs/guide/blueprints/fields>
- Source: <https://github.com/getkirby/kirby/tree/5.5.3/config/fields/time.php>

****

The time field is perfect for events or any other kind of time-based field content. It creates a select box with all available times of the date defined by certain interval.

<figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/time/5dd9fc40f4-1717846665/time.png?width=1416&amp;height=328&amp;enlarge=0"><img alt="" class="rounded" height="214" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/time/5dd9fc40f4-1717846665/time.png?width=924&amp;height=214&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/time/5dd9fc40f4-1717846665/time.png?width=462&amp;height=107&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/time/5dd9fc40f4-1717846665/time.png?width=690&amp;height=160&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/time/5dd9fc40f4-1717846665/time.png?width=924&amp;height=214&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/time/5dd9fc40f4-1717846665/time.png?width=1380&amp;height=320&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/time/5dd9fc40f4-1717846665/time.png?width=1416&amp;height=328&amp;enlarge=0 1848w" width="924"></a></figure>

## Example

```yaml
fields:
  time:
    label: Time
    type: time
```

## Field properties



<div class="table">
	<table class="parameters">
		<thead>
			<tr>
				<th>Name</th>
				<th>Type</th>
				<th>Default</th>

								<th>Description</th>
							</tr>
		</thead>
		<tbody>
						<tr>
				<td>
					after				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Optional text that will be shown after the input</td>
							</tr>
						<tr>
				<td>
					autofocus				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Sets the focus on this field when the form loads. Only the first field with this label gets</td>
							</tr>
						<tr>
				<td>
					before				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Optional text that will be shown before the input</td>
							</tr>
						<tr>
				<td>
					default				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Sets the default time when a new page/file/user is created</td>
							</tr>
						<tr>
				<td>
					disabled				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>If <code class="type type-bool">true</code>, the field is no longer editable and will not be saved</td>
							</tr>
						<tr>
				<td>
					display				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Custom format (dayjs tokens: <code class="type">HH</code>, <code class="type">hh</code>, <code class="type">mm</code>, <code class="type">ss</code>, <code class="type">a</code>) that is used to display the field in the Panel</td>
							</tr>
						<tr>
				<td>
					format				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Defines a custom format that is used when the field is saved</td>
							</tr>
						<tr>
				<td>
					help				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Optional help text below the field</td>
							</tr>
						<tr>
				<td>
					icon				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>'clock'</code>
									</td>

								<td>Changes the clock icon</td>
							</tr>
						<tr>
				<td>
					label				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>The field label can be set as string or associative array with translations</td>
							</tr>
						<tr>
				<td>
					max				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Latest time, which can be selected/saved (H:i or H:i:s)</td>
							</tr>
						<tr>
				<td>
					min				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Earliest time, which can be selected/saved (H:i or H:i:s)</td>
							</tr>
						<tr>
				<td>
					notation				</td>
				<td><code class="type type-int">int</code></td>

				<td data-label="Default:">
															<code>24</code>
									</td>

								<td><code class="type">12</code> or <code class="type">24</code> hour notation. If <code class="type">12</code>, an AM/PM selector will be shown. If <code class="type">display</code> is defined, that option will take priority.</td>
							</tr>
						<tr>
				<td>
					required				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>If <code class="type type-bool">true</code>, the field has to be filled in correctly to be saved.</td>
							</tr>
						<tr>
				<td>
					step				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Round to the nearest: sub-options for <code class="type">unit</code> (minute) and <code class="type">size</code> (5)</td>
							</tr>
						<tr>
				<td>
					translate				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>true</code>
									</td>

								<td>If <code class="type type-bool">false</code>, the field will be disabled in non-default languages and cannot be translated. This is only relevant in multi-language setups.</td>
							</tr>
						<tr>
				<td>
					when				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Conditions when the field will be shown (since 3.1.0)</td>
							</tr>
						<tr>
				<td>
					width				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>'1/1'</code>
									</td>

								<td>The width of the field in the field grid, e.g. <code class="type">1/1</code>, <code class="type">1/2</code>, <code class="type">1/3</code>, <code class="type">1/4</code>, <code class="type">2/3</code>, <code class="type">3/4</code></td>
							</tr>
					</tbody>
	</table>
</div>

## Display format

You can define the format of the time via the `display` option:

```yaml
display: HH:mm
display: hh:mm A
display: h.m.s a
```

| Token | Output | Description |
|--|--|--|
| `H` | 0-23 | Hour
| `HH` | 00-23 | Hour, 2-digits
| `h` | 1-12 | Hour, 12-hour clock
| `hh` | 01-12 | Hour, 12-hour clock, 2-digits
| `m` | 0-59 | Minute
| `mm` | 00-59 | Minute, 2-digits
| `s` | 0-59 | Second
| `ss` | 00-59 | Second, 2-digits
| `A` | AM PM | |
| `a` | am pm | |

The field will parse any input by matching it to the display format. `display: HH:ss` will match an input of `09:35`. It will also match partials or slight variations, e.g. `09`, `9`. The base for partials will be the current time.

## Notation

You can choose between the 12 hour (AM/PM) and the 24 hour format. The default is the 24 hour format.

```yaml
fields:
  time:
    label: Time
    type: time
    notation: 12
```

<info>
If you specify the `display` option, this will take priority (whether it includes `A`/`a`).
</info>

## Step

The `step` option allows you to define intervals of valid values. Any input to the field gets rounded to the nearest interval step. The default is 5 minutes. Possible values for unit are `hour`, `minute` and `second`.

```yaml
step:
  unit: minute
  size: 15

# only unit, size will default to `1`
step: hour

# only size, unit will default to `minute`
step: 10
```

## Default value

The default value can either be set to a specific time (e.g. `17:00`) – and will be matched with the closest interval option – or as `now`.

```yaml
fields:
  time:
    label: Time
    type: time
    default: now
```

## How to use in templates/snippets

The field stores its value in a standardized format in the content file: `H:i:s`. To output the field value as is:

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

Render time in 24 hour format

```php
<?= $page->time()->toDate('H:i') ?>
```

With timezone identifier:

```php
<?= $page->time()->toDate('H:i e') ?>
```

Render the time in 12 hour format with am/pm:

```php
<?= $page->time()->toDate('g:i a');
```