ภาพรวมของ Time Zone API
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Time Zone API คือบริการที่ยอมรับคำขอ HTTP ของ
พิกัดละติจูด/ลองจิจูด รวมถึงวันที่และเวลาที่เลือก แสดงเวลา
ข้อมูลโซนสำหรับสถานที่ตั้งนั้น รวมถึงการชดเชยเวลา UTC และการออมแสง
เหตุผลที่ควรใช้ Time Zone API
เมื่อใช้ Time Zone API คุณสามารถพัฒนาแอปพลิเคชันสำหรับ
รหัสเขตเวลาและชื่อสำหรับวันที่และเวลาในสถานที่ที่เจาะจง
บนแผนที่ เช่น คุณสามารถแสดงข้อมูลเขตเวลาต่อไปนี้
- ชื่อเขตเวลาที่แปลแล้วสำหรับตำแหน่งบนแผนที่จาก Google Maps Platform
- ปรับเขตเวลาจาก UTC และการปรับเวลาตามฤดูกาล
ข้อมูลเขตเวลาจะมีประโยชน์อย่างยิ่งเมื่อคุณต้องการให้เว็บไซต์หรือแอปแสดงข้อมูลที่อิงตามเวลาซึ่งเกี่ยวข้องกับผู้ใช้
คุณสามารถใช้ Time Zone API ทำอะไรได้บ้าง
เมื่อใช้ Time Zone API คุณจะขอเขตเวลาของสถานที่บนพื้นโลกได้ พร้อมทั้งเวลาออฟเซ็ตจาก UTC และเวลาออมแสงของแต่ละสถานที่
วิธีการทำงานของ Time Zone API
Time Zone API ยอมรับคําขอ HTTPS ของพิกัดละติจูด/ลองจิจูด วันและเวลาที่ต้องการเป็นการประทับเวลา และรหัสภาษา (ไม่บังคับ) โดยจะแสดงผลข้อมูลในรูปแบบที่คำขอระบุ
ตัวอย่างต่อไปนี้จะแสดงคำขอสำหรับ
เนวาดา สหรัฐอเมริกา โดยมีเอาต์พุตที่ขอใน JSON
https://maps.googleapis.com/maps/api/timezone/json
?location=39.6034810%2C-119.6822510
×tamp=1733428634
&key=YOUR_API_KEY
แหล่งข้อมูล
ตารางต่อไปนี้สรุปทรัพยากรที่มีผ่าน TimeZone API พร้อมกับข้อมูลที่แสดง
แหล่งข้อมูล |
ข้อมูลที่ส่งคืน |
รูปแบบการแสดงผล |
เขตเวลา
คุณระบุคำขอพร้อมตำแหน่งและการประทับเวลา ดูพารามิเตอร์ที่จําเป็น
|
- รหัสเขตเวลา
- ชื่อเขตเวลา (แปลหรือไม่ก็ได้)
- ค่าออฟเซ็ตจาก UTC เป็นวินาที
- ออฟเซ็ตสำหรับเวลาออมแสงเป็นวินาที
- โปรดดูตัวอย่างคำตอบในเขตเวลา
|
|
วิธีใช้ Time Zone API
1 |
เริ่มตั้งค่า |
เริ่มต้นด้วยตั้งค่าโปรเจ็กต์ Google Cloud แล้วทําตามวิธีการตั้งค่าที่ระบุไว้ |
2 |
ลองใช้คำขอเขตเวลา |
เมื่อมีคีย์ API แล้ว คุณสามารถเริ่มทดสอบ Time Zone API ได้โดยตรงจากเบราว์เซอร์ ดูรายละเอียดได้ในตัวอย่างเขตเวลาในคู่มือคำขอและคำตอบเกี่ยวกับเขตเวลา
|
3 |
ทำความเข้าใจพื้นฐานคำตอบ |
สำรวจวิธีใช้ข้อมูลเขตเวลาในแอปหรือเว็บไซต์
ดูรายละเอียดได้ในคำตอบเกี่ยวกับเขตเวลา
|
5 |
รวมข้อมูลเขตเวลาไว้ในแอปของคุณเอง |
คุณสามารถใช้ข้อมูลเขตเวลาเพื่อปรับปรุงแอปและเว็บไซต์สำหรับผู้ใช้ในภาษาต่างๆ ตามเขตเวลา
|
ไลบรารีของไคลเอ็นต์ที่ใช้ได้
เรียกใช้ API นี้ในภาษาที่ต้องการผ่านไลบรารีของไคลเอ็นต์อย่างใดอย่างหนึ่งต่อไปนี้
ไคลเอ็นต์ Java, ไคลเอ็นต์ Python, ไคลเอ็นต์ Go และไคลเอ็นต์ Node.js สำหรับบริการของ Google Maps เป็นไลบรารีของไคลเอ็นต์ที่ชุมชนสนับสนุนและเป็นโอเพนซอร์สภายใต้สัญญาอนุญาต Apache 2.0
ดาวน์โหลดได้จาก GitHub ซึ่งคุณจะดูวิธีการติดตั้งและโค้ดตัวอย่างได้ด้วย
ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-29 UTC
[null,null,["อัปเดตล่าสุด 2025-08-29 UTC"],[[["\u003cp\u003eThe Time Zone API provides time zone data, including UTC and daylight savings offsets, for specific locations based on latitude/longitude and timestamp.\u003c/p\u003e\n"],["\u003cp\u003eYou can use the API to display localized time zone names, offsets, and enhance time-based data in your applications.\u003c/p\u003e\n"],["\u003cp\u003eThe API accepts HTTPS requests with location and timestamp parameters and returns data in JSON or XML format.\u003c/p\u003e\n"],["\u003cp\u003eClient libraries are available in Java, Python, Go, and Node.js for easy integration into your projects.\u003c/p\u003e\n"]]],["The Time Zone API retrieves time zone data for specific locations using latitude/longitude coordinates and a timestamp. It returns the time zone ID, localized name, UTC offset, and daylight saving time offset in JSON or XML format. To use it, you send an HTTPS request with location and timestamp and you can then utilize the data in your website or apps to show time-based information relevant to users' locations. You can also use one of the provided client libraries to access the API.\n"],null,["# Time Zone API overview\n\nThe Time Zone API is a service that accepts an HTTP request of\nlatitude/longitude coordinates and a chosen date and time. It returns the time\nzone data for the location, including offsets for UTC and daylight savings\ntime.\n\nWhy use the Time Zone API\n-------------------------\n\nWith the Time Zone API, you can develop applications that provide\nthe time zone ID and name for dates and times at specific locations\non a map. For example, you can show the following\ntime zone data:\n\n- Localized time zone names for map locations from the Google Maps Platform.\n- Time zone offsets from UTC and for daylight savings.\n\nTime zone data can be particularly useful when you want to have your\nwebsite or app display time-based data relevant to your users.\n\nWhat you can do with the Time Zone API\n--------------------------------------\n\nWith the Time Zone API, you can request the time zone for\nlocations on the surface of the earth, with the time offset from\nUTC and for daylight savings time for each of\nthose locations.\n\nHow the Time Zone API works\n---------------------------\n\nThe Time Zone API accepts an HTTPS request of latitude/longitude\ncoordinates, the desired date and time as a timestamp, and optionally,\na language code. It returns data in the format specified by the request.\nThe following example shows a request for\nNevada, USA, with a requested output in JSON. \n\n```scdoc\n https://maps.googleapis.com/maps/api/timezone/json\n ?location=39.6034810%2C-119.6822510\n ×tamp=1733428634\n &key=YOUR_API_KEY\n \n```\n\n### Resources\n\nThe following table summarizes the resources available through the\nTime Zone API along with the data it returns.\n\n| Data resources | Data returned | Return format |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|\n| **Timezone** You provide your request along with location and timestamp. See [required parameters](/maps/documentation/timezone/requests-timezone#required-parameters). | - Time zone ID. - Time zone name, optionally localized - Offset from UTC, in seconds - Offset for DST, in seconds - See Time Zone for specific response examples. | - JSON - XML |\n\nHow to use the Time Zone API\n----------------------------\n\n|---|--------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1 | **Get set up** | Start with [Set up your Google Cloud project](/maps/documentation/elevation/cloud-setup) and complete the setup instructions that follow. |\n| 2 | **Try a timezone request** | Once you have an API key, you can start testing out the Time Zone API directly from your browser. See [Time Zone examples](/maps/documentation/timezone/requests-timezone#examples) in the Timezone requests and responses guide for details. |\n| 3 | **Understand response basics** | Explore how to use timezone data in your app or website. See [Time Zone responses](/maps/documentation/timezone/requests-timezone#responses) for details. |\n| 5 | **Incorporate timezone data into your own app!** | You can use timezone data to enhance apps and websites for users across different time-based locales. |\n\n### Available client libraries\n\nCall this API in the language of\nyour choice through one of the following client libraries:\n\n- [Java\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-java)\n- [Python\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-python)\n- [Go Client\n for Google Maps Services](https://github.com/googlemaps/google-maps-services-go)\n- [Node.js\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-js)\n\nThe Java Client, Python Client, Go Client and Node.js Client for Google Maps\nServices are community-supported client libraries, open sourced under the\n[Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).\nDownload them from GitHub, where you can also find installation instructions and sample code.\n\nWhat's next\n-----------\n\n- **Learn how to make Time Zone requests** : Go to [Time Zone Requests and responses](/maps/documentation/timezone/requests-timezone).\n- **Follow best practices** : Go to [Web Services Best Practices](/maps/documentation/timezone/web-service-best-practices)."]]