Class TimePicker
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Bộ chọnthời gian
Trường nhập cho phép người dùng nhập thời gian.
Có sẵn cho các tiện ích bổ sung của Google Workspace và ứng dụng Google Chat.
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'),
);
Tài liệu chi tiết
setFieldName(fieldName)
Đặt tên trường xác định bộ chọn này trong đối tượng sự kiện được tạo khi có tương tác với giao diện người dùng. Người dùng sẽ nhìn thấy tên trường. Bắt buộc; tên trường được chỉ định phải là duy nhất.
Thông số
Tên | Loại | Mô tả |
fieldName | String | Tên cần chỉ định cho dữ liệu đầu vào này. |
Cầu thủ trả bóng
TimePicker
– Bộ chọn này, để tạo chuỗi.
setHours(hours)
Đặt giá trị giờ được điền sẵn để đặt trong trường nhập.
Thông số
Tên | Loại | Mô tả |
hours | Integer | Giá trị giờ mặc định được đặt trong dữ liệu đầu vào, trong khoảng từ 0 đến 23. Loại này luôn được biểu thị dưới dạng chuỗi trong các tham số lệnh gọi lại của biểu mẫu. |
Cầu thủ trả bóng
TimePicker
– Bộ chọn này, để tạo chuỗi.
setMinutes(minutes)
Đặt giá trị phút được điền sẵn để đặt trong trường nhập.
Thông số
Tên | Loại | Mô tả |
minutes | Integer | Giá trị phút mặc định được đặt trong dữ liệu đầu vào, trong khoảng từ 0 đến 59. Loại này luôn được biểu thị dưới dạng chuỗi trong các tham số lệnh gọi lại của biểu mẫu. |
Cầu thủ trả bóng
TimePicker
– Bộ chọn này, để tạo chuỗi.
setOnChangeAction(action)
Đặt một Action
mà tập lệnh thực hiện bất cứ khi nào dữ liệu đầu vào của bộ chọn thay đổi.
Thông số
Tên | Loại | Mô tả |
action | Action | Hành động cần thực hiện. |
Cầu thủ trả bóng
TimePicker
– Bộ chọn này, để tạo chuỗi.
setTitle(title)
Đặt tiêu đề hiển thị phía trên trường nhập.
Thông số
Tên | Loại | Mô tả |
title | String | Tiêu đề trường nhập. |
Cầu thủ trả bóng
TimePicker
– Bộ chọn này, để tạo chuỗi.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eTimePicker is an input field that allows users to input a time, available for Google Workspace Add-ons and Google Chat apps.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can prefill the TimePicker with a default time using \u003ccode\u003esetHours\u003c/code\u003e and \u003ccode\u003esetMinutes\u003c/code\u003e, and set a title using \u003ccode\u003esetTitle\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003esetFieldName\u003c/code\u003e assigns a unique identifier for the picker, used in event objects for UI interactions.\u003c/p\u003e\n"],["\u003cp\u003eAn \u003ccode\u003eOnChangeAction\u003c/code\u003e can be set to trigger a specific script function whenever the picker's input value is modified.\u003c/p\u003e\n"]]],[],null,["# Class TimePicker\n\nTimePicker\n\nAn input field that allows users to input a time.\n\nAvailable for Google Workspace add-ons and Google Chat apps.\n\n```javascript\nconst dateTimePicker =\n CardService.newTimePicker()\n .setTitle('Enter the time.')\n .setFieldName('time_field')\n // Set default value as 3:30 AM.\n .setHours(3)\n .setMinutes(30)\n .setOnChangeAction(\n CardService.newAction().setFunctionName('handleDateTimeChange'),\n );\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------|\n| [setFieldName(fieldName)](#setFieldName(String)) | [TimePicker](#) | Sets the field name that identifies this picker in the event object that is generated when there is a UI interaction. |\n| [setHours(hours)](#setHours(Integer)) | [TimePicker](#) | Sets the prefilled hours value to set in the input field. |\n| [setMinutes(minutes)](#setMinutes(Integer)) | [TimePicker](#) | Sets the prefilled minutes value to set in the input field. |\n| [setOnChangeAction(action)](#setOnChangeAction(Action)) | [TimePicker](#) | Sets an [Action](/apps-script/reference/card-service/action) that the script performs whenever the picker input changes. |\n| [setTitle(title)](#setTitle(String)) | [TimePicker](#) | Sets the title displayed above the input field. |\n\nDetailed documentation\n----------------------\n\n### `set``Field``Name(fieldName)`\n\nSets the field name that identifies this picker in the event object that is generated when\nthere is a UI interaction. The field name is visible to the user. Required; the specified field\nname must be unique.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------|----------|-----------------------------------|\n| `field``Name` | `String` | The name to assign to this input. |\n\n#### Return\n\n\n[TimePicker](#) --- This picker, for chaining.\n\n*** ** * ** ***\n\n### `set``Hours(hours)`\n\nSets the prefilled hours value to set in the input field.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|-----------|---------------------------------------------------------------------------------------------------------------------------------------|\n| `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. |\n\n#### Return\n\n\n[TimePicker](#) --- This picker, for chaining.\n\n*** ** * ** ***\n\n### `set``Minutes(minutes)`\n\nSets the prefilled minutes value to set in the input field.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------|-----------|------------------------------------------------------------------------------------------------------------------------------------------|\n| `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. |\n\n#### Return\n\n\n[TimePicker](#) --- This picker, for chaining.\n\n*** ** * ** ***\n\n### `set``On``Change``Action(action)`\n\nSets an [Action](/apps-script/reference/card-service/action) that the script performs whenever the picker input changes.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|------------------------------------------------------|---------------------|\n| `action` | [Action](/apps-script/reference/card-service/action) | The action to take. |\n\n#### Return\n\n\n[TimePicker](#) --- This picker, for chaining.\n\n*** ** * ** ***\n\n### `set``Title(title)`\n\nSets the title displayed above the input field.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|------------------------|\n| `title` | `String` | The input field title. |\n\n#### Return\n\n\n[TimePicker](#) --- This picker, for chaining."]]