Class TimePicker
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เครื่องมือเลือกเวลา
ช่องป้อนข้อมูลซึ่งอนุญาตให้ผู้ใช้ป้อนเวลา
พร้อมใช้งานสำหรับส่วนเสริมของ Google Workspace และแอป 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'),
);
เอกสารประกอบโดยละเอียด
setFieldName(fieldName)
ตั้งค่าชื่อฟิลด์ที่ระบุเครื่องมือเลือกนี้ในออบเจ็กต์เหตุการณ์ที่สร้างขึ้นเมื่อมีการทำงานกับ UI ผู้ใช้จะเห็นชื่อช่อง ต้องระบุ ชื่อช่องที่ระบุต้องไม่ซ้ำกัน
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
fieldName | String | ชื่อที่จะกําหนดให้กับอินพุตนี้ |
รีเทิร์น
TimePicker
— เครื่องมือเลือกนี้สําหรับการต่อเชื่อม
setHours(hours)
ตั้งค่าชั่วโมงที่กรอกไว้ล่วงหน้าในช่องป้อนข้อมูล
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
hours | Integer | ค่าชั่วโมงเริ่มต้นที่ใส่ไว้ในอินพุต ซึ่งอยู่ในช่วง 0 ถึง 23 โดยระบบจะแสดงเป็นสตริงในพารามิเตอร์การเรียกกลับของแบบฟอร์มเสมอ |
รีเทิร์น
TimePicker
— เครื่องมือเลือกนี้สําหรับการต่อเชื่อม
setMinutes(minutes)
ตั้งค่านาทีที่กรอกไว้ล่วงหน้าในช่องป้อนข้อมูล
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
minutes | Integer | ค่านาทีเริ่มต้นที่ใส่ไว้ในอินพุต ซึ่งอยู่ในช่วง 0 ถึง 59 โดยระบบจะแสดงเป็นสตริงในพารามิเตอร์การเรียกกลับของแบบฟอร์มเสมอ |
รีเทิร์น
TimePicker
— เครื่องมือเลือกนี้สําหรับการต่อเชื่อม
setOnChangeAction(action)
ตั้งค่า Action
ที่สคริปต์จะดำเนินการทุกครั้งที่อินพุตเครื่องมือเลือกมีการเปลี่ยนแปลง
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
action | Action | สิ่งที่ต้องดำเนินการ |
รีเทิร์น
TimePicker
— เครื่องมือเลือกนี้สําหรับการต่อเชื่อม
setTitle(title)
ตั้งค่าชื่อที่แสดงเหนือช่องป้อนข้อมูล
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
title | String | ชื่อช่องป้อนข้อมูล |
รีเทิร์น
TimePicker
— เครื่องมือเลือกนี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 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."]]