Class DateTimePicker

DateTimePicker

An input field that allows users to input a date and time.

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

var dateTimePicker = CardService.newDateTimePicker()
    .setTitle("Enter the date and time.")
    .setFieldName("date_time_field")
    // Set default value as Jan 1, 2018, 3:00 AM UTC. Either a number or string is acceptable.
    .setValueInMsSinceEpoch(1514775600)
    // EDT time is 5 hours behind UTC.
    .setTimeZoneOffsetInMins(-5 * 60)
    .setOnChangeAction(CardService.newAction()
        .setFunctionName("handleDateTimeChange"));

Methods

MethodReturn typeBrief description
setFieldName(fieldName)DateTimePickerSets the field name that identifies this picker in the event object that is generated when there is a UI interaction.
setOnChangeAction(action)DateTimePickerSets an Action that the script performs whenever the picker input changes.
setTimeZoneOffsetInMins(timeZoneOffsetMins)DateTimePickerSets the number of minutes that the time zone should be offset from UTC.
setTitle(title)DateTimePickerSets the title displayed above the input field.
setValueInMsSinceEpoch(valueMsEpoch)DateTimePickerSets the prefilled value to be set in the input field.
setValueInMsSinceEpoch(valueMsEpoch)DateTimePickerSets the prefilled value to be set in 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

DateTimePicker — 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

DateTimePicker — This picker, for chaining.


setTimeZoneOffsetInMins(timeZoneOffsetMins)

Sets the number of minutes that the time zone should be offset from UTC. If set, the date and time is displayed in the specified time zone. If not set, the time is displayed in the user's time zone.

Parameters

NameTypeDescription
timeZoneOffsetMinsIntegerThe number of minutes that the time zone is offset from UTC.

Return

DateTimePicker — This picker, for chaining.


setTitle(title)

Sets the title displayed above the input field.

Parameters

NameTypeDescription
titleStringThe input field title.

Return

DateTimePicker — This picker, for chaining.


setValueInMsSinceEpoch(valueMsEpoch)

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

Parameters

NameTypeDescription
valueMsEpochNumberThe default value placed in the input as a number, in milliseconds since the epoch. It is always represented as a string in the form callback parameters.

Return

DateTimePicker — This picker, for chaining.


setValueInMsSinceEpoch(valueMsEpoch)

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

Parameters

NameTypeDescription
valueMsEpochStringThe default value placed in the input as a string, in milliseconds since the epoch. It is always represented as a string in the form callback parameters.

Return

DateTimePicker — This picker, for chaining.