Class TimePicker

TimePicker

An input field that allows users to input a time.

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

var 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

MethodReturn typeBrief description
setFieldName(fieldName)TimePickerSets the field name that identifies this picker in the event object that is generated when there is a UI interaction.
setHours(hours)TimePickerSets the prefilled hours value to set in the input field.
setMinutes(minutes)TimePickerSets the prefilled minutes value to set in the input field.
setOnChangeAction(action)TimePickerSets an Action that the script performs whenever the picker input changes.
setTitle(title)TimePickerSets the title displayed above the input field.

Detailed documentation

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

NameTypeDescription
fieldNameStringThe 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

NameTypeDescription
hoursIntegerThe 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.


setMinutes(minutes)

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

Parameters

NameTypeDescription
minutesIntegerThe 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

NameTypeDescription
actionActionThe action to take.

Return

TimePicker — This picker, for chaining.


setTitle(title)

Sets the title displayed above the input field.

Parameters

NameTypeDescription
titleStringThe input field title.

Return

TimePicker — This picker, for chaining.