Not supported by Chat apps. Support by Chat apps coming soon.
The DateTimePicker
widget lets users specify a date, a time, or both a date and time.
It accepts text input from users, but features an interactive date and time selector that helps users enter formatted dates and times. If users enter a date or time incorrectly, the widget shows an error that prompts users to enter the correct format.
Chat apps receive and can process the value of user-entered dates and times during form input events. For details about working with form inputs, see Receive form data.
Example
The following image displays a card consisting of a DateTimePicker
widget:

DateTimePicker
widgets: one for selecting both date and time, one for just date, and one for just time.
Here's the card's JSON:
JSON
{
"cardsV2": [
{
"cardId": "exampleCard",
"card": {
"sections": [
{
"widgets": [
{
"textParagraph": {
"text": "A datetime picker widget with both date and time:"
}
},
{
"divider": {}
},
{
"dateTimePicker": {
"name": "date_time_picker_date_and_time",
"label": "meeting",
"type": 'DATE_AND_TIME',
}
},
{
"textParagraph": {
"text": "A datetime picker widget with just date:"
}
},
{
"divider": {}
},
{
"dateTimePicker": {
"name": "date_time_picker_date_and_time",
"label": "Choose a date",
"type": 'DATE_ONLY',
}
},
{
"textParagraph": {
"text": "A datetime picker widget with just time:"
}
},
{
"divider": {}
},
{
"dateTimePicker": {
"name": "date_time_picker_date_and_time",
"label": "Select a time",
"type": 'TIME_ONLY',
}
},
]
}
]
}
}
]
}
DateTimePicker
JSON representation and fields
JSON representation |
---|
{ "name": string, "label": string, "type": enum ( |
Fields | |
---|---|
name
|
The name by which the datetime picker is identified in a form input event. For details about working with form inputs, see Receive form data . |
label
|
The text that prompts users to enter a date, time, or datetime. Specify text that helps the user enter the information your app needs. For example, if users are setting an appointment, then a label like "Appointment date" or "Appointment date and time" might work well. |
type
|
What kind of date and time input the datetime picker supports. |
valueMsEpoch
|
The value displayed as the default value before user input or previous user input, represented in milliseconds ( Epoch time ).
For
For
For
|
timezoneOffsetDate
|
The number representing the time zone offset from UTC, in minutes. If set, the
|
onChangeAction
|
Triggered when the user clicks Save or Clear from the datetime picker interface. |
DateTimePickerType
Enums | |
---|---|
DATE_AND_TIME
|
The user can select a date and time. |
DATE_ONLY
|
The user can only select a date. |
TIME_ONLY
|
The user can only select a time. |
Action
An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. If the action is triggered, the form values are sent to the server.
JSON representation |
---|
{ "function": string, "parameters": [ { object ( |
Fields | |
---|---|
function
|
A custom function to invoke when the containing element is clicked or othrwise activated. For example usage, see Create interactive cards . |
parameters[]
|
List of action parameters. |
loadIndicator
|
Specifies the loading indicator that the action displays while making the call to the action. |
persistValues
|
Indicates whether form values persist after the action. The default value is
If
If
|
interaction
|
Optional. Required when opening a dialog . What to do in response to an interaction with a user, such as a user clicking button on a card message.
If unspecified, the app responds by executing an
By specifying an
When specified, a loading indicator is not shown. Supported by Chat apps, but not Google Workspace Add-ons. If specified for an add-on, the entire card is stripped and nothing is shown in the client. |
ActionParameter
List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters.
To learn more, see CommonEventObject .
JSON representation |
---|
{ "key": string, "value": string } |
Fields | |
---|---|
key
|
The name of the parameter for the action script. |
value
|
The value of the parameter. |
LoadIndicator
Specifies the loading indicator that the action displays while making the call to the action.
Enums | |
---|---|
SPINNER
|
Displays a spinner to indicate that content is loading. |
NONE
|
Nothing is displayed. |
Interaction
Optional. Required when opening a dialog .
What to do in response to an interaction with a user, such as a user clicking button on a card message.
If unspecified, the app responds by executing an
action
- like opening a link or running a function - as normal.
By specifying an
interaction
, the app can respond in special interactive ways. For example, by setting
interaction
to
OPEN_DIALOG
, the app can open a
dialog
.
When specified, a loading indicator is not shown.
Supported by Chat apps, but not Google Workspace Add-ons. If specified for an add-on, the entire card is stripped and nothing is shown in the client.
Enums | |
---|---|
INTERACTION_UNSPECIFIED
|
Default value. The
action
executes as normal.
|
OPEN_DIALOG
|
Opens a dialog , a windowed, card-based interface that Chat apps use to interact with users. Only supported by Chat apps in response to button-clicks on card messages. Not supported by Google Workspace Add-ons. If specified for an add-on, the entire card is stripped and nothing is shown in the client. |