시작하기

컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.

Time Zone API는 지표면의 위치에 대한 시차 데이터를 제공합니다. 특정 위도/경도 쌍 및 날짜의 시간대 정보를 요청합니다. API는 해당 시간대의 이름, UTC로부터의 시간 오프셋, 일광 절약 시간 오프셋을 반환합니다.

샘플 요청 및 응답

위도/경도 좌표를 사용하여 URL 문자열로 구성된 요청과 함께 HTTPS 인터페이스를 통해 Time Zone API에 액세스합니다. location, timestamp, 날짜, API 키를 지정합니다.

아래 쿼리는 미국 네바다에 대해 시간대 요청을 수행합니다. 타임스탬프는 2012년 3월 8일로 설정됩니다.

URL

https://maps.googleapis.com/maps/api/timezone/json
  ?location=39.6034810%2C-119.6822510
  &timestamp=1331161200
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331161200&key=YOUR_API_KEY'

자바스크립트

var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331161200&key=YOUR_API_KEY',
  headers: { }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

Python

import requests

url = "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331161200&key=YOUR_API_KEY"

payload={}
headers = {}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

자바

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331161200&key=YOUR_API_KEY")
  .method("GET", body)
  .build();
Response response = client.newCall(request).execute();

Ruby

require "uri"
require "net/http"

url = URI("https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331161200&key=YOUR_API_KEY")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)

response = https.request(request)
puts response.read_body

Go

package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&key=YOUR_API_KEY"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

우체국

OpenAPI 사양Postman 컬렉션으로도 제공됩니다.

Postman에서 실행

웹브라우저에 URL을 입력하여 이를 테스트할 수 있습니다. YOUR_API_KEY실제 API 키로 바꿔야 합니다. 응답에는 지정된 위치와 날짜 (timestamp)의 시간대 데이터가 포함됩니다.

개발자 가이드에서 요청 URL 및 사용 가능한 매개변수 빌드응답 이해에 대해 자세히 알아보세요.

다음은 JSON 형식의 샘플 응답입니다.

JSON

{
  "dstOffset": 0,
  "rawOffset": -28800,
  "status": "OK",
  "timeZoneId": "America/Los_Angeles",
  "timeZoneName": "Pacific Standard Time",
}

XML

<TimeZoneResponse>
 <status>OK</status>
 <raw_offset>-28800.0000000</raw_offset>
 <dst_offset>0.0000000</dst_offset>
 <time_zone_id>America/Los_Angeles</time_zone_id>
 <time_zone_name>Pacific Standard Time</time_zone_name>
</TimeZoneResponse>

클라이언트 라이브러리로 코딩 시작하기

클라이언트 라이브러리를 사용하면 인증, 요청 제한, 자동 재시도와 같은 일반적인 작업의 간단한 기본 구현을 제공하여 Google 지도 웹 서비스 API로 더 쉽게 개발할 수 있습니다. Time Zone API는 Google 지도 서비스용 자바 클라이언트, Python 클라이언트, Go 클라이언트, Node.js 클라이언트에서 사용할 수 있습니다.

인증, 할당량, 가격 책정, 정책

인증

Time Zone API를 사용하려면 먼저 API를 사용 설정하고 적절한 인증 사용자 인증 정보를 획득해야 합니다. 자세한 내용은 Google Maps Platform 시작하기를 참고하세요.

할당량 및 가격 책정

Time Zone API에 설정된 할당량과 가격 책정에 대한 자세한 내용은 사용량 및 결제 페이지를 확인하세요.

정책

Time API를 사용할 때는 API 정책을 준수해야 합니다.

자세히 알아보기

Time Zone API에서 기본값(영어) 이외의 언어로 결과를 반환하도록 언어 매개변수를 설정할 수도 있습니다. 더 많은 예와 기타 세부정보는 Time Zone API 개발자 가이드를 참고하세요.

Time Zone API 개발자 가이드는 Google Maps Platform API에서 제공하는 지도에 시간 데이터를 포함하려는 웹사이트 및 모바일 개발자를 대상으로 합니다. API 사용에 관한 소개 및 사용 가능한 매개변수에 관한 참조 자료입니다.