Time Zone API 總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Time Zone API 服務接受 HTTP 要求
經緯度座標以及所選日期和時間。其會傳回時間
位置的區域資料,包括世界標準時間和日光節約時間的偏移量
讓應用程式從可以最快做出回應的位置
回應使用者要求
使用 Time Zone API 的原因
透過 Time Zone API,您可以開發應用程式
特定地區的日期和時間的時區 ID 和名稱
。舉例來說,您可以顯示下列時區資料:
- Google 地圖平台中地圖位置的本地化時區名稱。
- 時區與世界標準時間的偏移值,以及日光節約時間。
如果您希望網站或應用程式顯示與使用者相關的時間資料,時區資料就特別實用。
Time Zone API 的用途
您可以使用 Time Zone API 要求地球表面上各個位置的時區,以及這些位置相對於世界標準時間的時間偏移量,以及夏令時間。
Time Zone API 的運作方式
時區 API 會接受經緯度座標的 HTTPS 要求、所需日期和時間做為時間戳記,以及選用的語言代碼。並以要求指定的格式傳回資料。
以下範例顯示美國內華達州的資料要求,並要求以 JSON 格式傳回輸出內容。
https://maps.googleapis.com/maps/api/timezone/json
?location=39.6034810%2C-119.6822510
×tamp=1733428634
&key=YOUR_API_KEY
資源
下表概略說明透過 Time Zone API 可用的資源,以及該 API 傳回的資料。
資料資源 |
傳回的資料 |
傳回格式 |
時區
提出要求時,請一併提供位置和時間戳記。請參閱必要參數。
|
- 時區 ID。
- 時區名稱 (選用本地化)
- 與世界標準時間的偏移量 (以秒為單位)
- 夏令時間的偏移量 (以秒為單位)
- 如需具體回應範例,請參閱「時區」。
|
|
如何使用 Time Zone API
1 |
做好準備 |
請先設定 Google Cloud 專案,然後完成後續的設定說明。 |
2 |
嘗試使用時區要求 |
取得 API 金鑰後,您就可以直接透過瀏覽器測試 Time Zone API。詳情請參閱「時區要求和回應」指南中的「時區範例」。 |
3 |
瞭解回覆的基本概念 |
瞭解如何在應用程式或網站中使用時區資料。
查看時區回應
。
|
5 |
將時區資料加入自己的應用程式! |
您可以使用時區資料,為不同時區的使用者改善應用程式和網站。 |
可用的用戶端程式庫
如要呼叫這個 API,請使用
從以下用戶端程式庫中擇一:
Google 地圖服務適用的 Java、Python、Go 和 Node.js 用戶端都是社群支援的用戶端程式庫,並依據 Apache 2.0 授權的條款提供開放原始碼。您可以從 GitHub 下載這些用戶端或相關貢獻項目,並查看安裝操作說明和程式碼範例。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[[["\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)."]]