# Class TimePicker

TimePicker

An input field that allows users to input a time.

Available for Google Workspace add-ons and Google Chat apps.

```javascript
const dateTimePicker =
    CardService.newTimePicker()
        .setTitle('Enter the time.')
        .setFieldName('time_field')
        // Set default value as 3:30 AM.
        .setHours(3)
        .setMinutes(30)
        .setOnChangeAction(
            CardService.newAction().setFunctionName('handleDateTimeChange'),
        );
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `addEventAction(eventAction)` | `Widget` | Adds the event action that can be performed on the widget. |
| `setFieldName(fieldName)` | `TimePicker` | Sets the field name that identifies this picker in the event object that is generated when there is a UI interaction. |
| `setHours(hours)` | `TimePicker` | Sets the prefilled hours value to set in the input field. |
| `setId(id)` | `Widget` | Sets the unique ID assigned that's used to identify the widget to be mutated. |
| `setMinutes(minutes)` | `TimePicker` | Sets the prefilled minutes value to set in the input field. |
| `setOnChangeAction(action)` | `TimePicker` | Sets an `Action` that the script performs whenever the picker input changes. |
| `setTitle(title)` | `TimePicker` | Sets the title displayed above the input field. |
| `setVisibility(visibility)` | `Widget` | Sets the visibility of the widget. |

## Detailed documentation

### `addEventAction(eventAction)`

Adds the event action that can be performed on the widget.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `eventAction` | `EventAction` | The `EventAction` to be added. |

#### Return


`Widget` --- The Object, for chaining.

*** ** * ** ***

### `setFieldName(fieldName)`

Sets the field name that identifies this picker in the event object that is generated when
there is a UI interaction. The field name is visible to the user. Required; the specified field
name must be unique.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `fieldName` | `String` | The name to assign to this input. |

#### Return


`TimePicker` --- This picker, for chaining.

*** ** * ** ***

### `setHours(hours)`

Sets the prefilled hours value to set in the input field.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `hours` | `Integer` | The default hour value placed in the input, range from 0 to 23. It is always represented as a string in the form callback parameters. |

#### Return


`TimePicker` --- This picker, for chaining.

*** ** * ** ***

### `setId(id)`

Sets the unique ID assigned that's used to identify the widget to be mutated. Widget mutation
is only supported in Add-Ons.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `id` | `String` | The id of the widget, with a limit of 64 characters and in format of \`\[a-zA-Z0-9-\]+\`. |

#### Return


`Widget` --- This object, for chaining.

*** ** * ** ***

### `setMinutes(minutes)`

Sets the prefilled minutes value to set in the input field.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `minutes` | `Integer` | The default minutes value placed in the input, range from 0 to 59. It is always represented as a string in the form callback parameters. |

#### Return


`TimePicker` --- This picker, for chaining.

*** ** * ** ***

### `setOnChangeAction(action)`

Sets an `Action` that the script performs whenever the picker input changes.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `action` | `Action` | The action to take. |

#### Return


`TimePicker` --- This picker, for chaining.

*** ** * ** ***

### `setTitle(title)`

Sets the title displayed above the input field.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `title` | `String` | The input field title. |

#### Return


`TimePicker` --- This picker, for chaining.

*** ** * ** ***

### `setVisibility(visibility)`

Sets the visibility of the widget. The default value is \`VISIBLE\`.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `visibility` | `Visibility` | The `Visibility` of the widget. |

#### Return


`Widget` --- The Object, for chaining.