# Time picker element

Allows users to choose a time from a list or type it in.

| | |
|---|---|
| **Type** | `timepicker` |
| **Available in** | Messages, Modals, Home tab |
| **Works in blocks** | [Section block](https://workstation.repzo.com/docs/developers/block-kit/blocks/section-block), [Actions block](https://workstation.repzo.com/docs/developers/block-kit/blocks/actions-block), [Input block](https://workstation.repzo.com/docs/developers/block-kit/blocks/input-block) |

## Usage

Picking a time sends your app a `block_actions` payload with the time as `selected_time` (`HH:mm`, 24-hour):

```json
{
  "type": "timepicker",
  "action_id": "standup_time",
  "block_id": "standup",
  "placeholder": { "type": "plain_text", "text": "Select a time" },
  "selected_time": "09:30",
  "action_ts": "1793786400.000000"
}
```

The time has no time zone attached: it's the time the reader picked.

See the [button element](https://workstation.repzo.com/docs/developers/block-kit/elements/button-element) for the rest of the payload.

The current value is also reported in `state.values[block_id][action_id]` (as `{ "type": …, <value field> }`) of every later interaction with the same message or view.

Inside an [input block](https://workstation.repzo.com/docs/developers/block-kit/blocks/input-block), changing the value sends nothing on its own: your app reads it from `view.state.values` in the `view_submission` payload. Set `dispatch_action: true` on the input block to also receive a `block_actions` payload on every change.

## Fields

| Field | Type | Description | Required? |
|---|---|---|---|
| `type` | String | The type of element. In this case `type` is always `timepicker`. | Required |
| `action_id` | String | An identifier for the action triggered when a time is selected. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other `action_id`s in the containing block. Maximum length is 255 characters. If you leave it out, Repzo generates one. | Optional |
| `initial_time` | String | The initial time that is selected when the element is loaded. This should be in the format `HH:mm`, where `HH` is the 24-hour format of an hour (00 to 23) and `mm` is minutes with leading zeros (00 to 59), for example `22:25` for 10:25pm. | Optional |
| `confirm` | [Confirmation dialog object](https://workstation.repzo.com/docs/developers/block-kit/objects/confirmation-dialog-object) | A confirm object that defines an optional confirmation dialog that appears after a time is selected. If the reader cancels, nothing is sent to your app. | Optional |
| `focus_on_load` | Boolean | Indicates whether the element will be set to auto focus within the view. Only one element can be set to `true`. Defaults to `false`. | Optional |
| `placeholder` | [Text object](https://workstation.repzo.com/docs/developers/block-kit/objects/text-object) | A `plain_text` only text object that defines the placeholder text shown on the time picker. Maximum length for the `text` in this field is 150 characters. | Optional |
| `timezone` | String | A time zone in the IANA format, for example `Asia/Riyadh`. Accepted for Slack compatibility; see the notes below. | Optional |

> **How Repzo Chat differs from Slack**
>
> - `timezone` isn't shown under the picker and isn't passed back to your app.
> - `focus_on_load` is accepted but not applied to this element yet.

## Examples

### A section with a time picker

```json
{
  "blocks": [
    {
      "type": "section",
      "block_id": "standup",
      "text": {
        "type": "mrkdwn",
        "text": "What time should the daily *sales stand-up* reminder go out?"
      },
      "accessory": {
        "type": "timepicker",
        "action_id": "standup_time",
        "initial_time": "09:30",
        "placeholder": {
          "type": "plain_text",
          "text": "Select a time"
        }
      }
    }
  ]
}
```

### A date and a time picker in an actions block

```json
{
  "blocks": [
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "Book the quarterly review with *Acme Logistics*:"
      }
    },
    {
      "type": "actions",
      "block_id": "qbr_acme",
      "elements": [
        {
          "type": "datepicker",
          "action_id": "qbr_date",
          "placeholder": {
            "type": "plain_text",
            "text": "Date"
          }
        },
        {
          "type": "timepicker",
          "action_id": "qbr_time",
          "initial_time": "14:00",
          "placeholder": {
            "type": "plain_text",
            "text": "Time"
          }
        }
      ]
    }
  ]
}
```

## Related

- [Block elements](https://workstation.repzo.com/docs/developers/block-kit/elements)
- [Block Kit overview](https://workstation.repzo.com/docs/developers/block-kit)
