Class TimePicker

Time Picker

An input field that allows users to input a time.

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

 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
Time Picker Sets the field name that identifies this picker in the event object that is generated when there is a UI interaction.
Time Picker Sets the prefilled hours value to set in the input field.
Time Picker Sets the prefilled minutes value to set in the input field.
Time Picker Sets an Action that the script performs whenever the picker input changes.
Time Picker Sets the title displayed above the input field.

Detailed documentation

set Field Name(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
field Name
String The name to assign to this input.

Return

Time Picker — This picker, for chaining.


set Hours(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

Time Picker — This picker, for chaining.


set Minutes(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

Time Picker — This picker, for chaining.


set On Change Action(action)

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

Parameters

Name Type Description
action
Action The action to take.

Return

Time Picker — This picker, for chaining.


set Title(title)

Sets the title displayed above the input field.

Parameters

Name Type Description
title
String The input field title.

Return

Time Picker — This picker, for chaining.

Design a Mobile Site
View Site in Mobile | Classic
Share by: