Convert Meeting Time Across TimeZones
Do You Have Your Access Token?
Before you proceed, ensure you have your access token at hand. Can't find your token? No worries — our guide will assist you in either creating a new one or finding your existing token.
LocationIQ's Timezone API provides a powerful solution for converting meeting times across different timezones, especially when you only have the geographic coordinates of the participants' locations. This guide will walk you through the process of using the LocationIQ Timezone API to convert a meeting time from one location to multiple others.
Gather Meeting Details
Collect the necessary information for the meeting:
- Meeting time in the origin timezone (e.g., 11:00 AM New York time)
- Date of the meeting (e.g., November 14, 2024)
- Coordinates (latitude and longitude) of all relevant locations
Craft the API Request
The API request URL format is as follows:
https://us1.locationiq.com/v1/timezone?key=YOUR_ACCESS_TOKEN&lat=LATITUDE&lon=LONGITUDE×tamp=UNIX_TIMESTAMP- Replace
YOUR_ACCESS_TOKENwith your actual API access token LATITUDEandLONGITUDEare the coordinates of the locationUNIX_TIMESTAMPis the Unix epoch time for the desired moment (optional, defaults to current time if omitted)
Make API Requests
Use the crafted API URL to fetch timezone information for each desired location:
locations = {
"New York": (40.7128, -74.0060),
"San Francisco": (37.7749, -122.4194),
"London": (51.5074, -0.1278),
"Cape Town": (-33.9249, 18.4241),
"Singapore": (1.3521, 103.8198),
"Tokyo": (35.6762, 139.6503)
}
base_url = "https://us1.locationiq.com/v1/timezone?key=YOUR_ACCESS_TOKEN&lat={}&lon={}×tamp={}"
meeting_timestamp = 1731600000 # Unix timestamp for November 14, 2024, 11:00 AM New York time
for city, coords in locations.items():
url = base_url.format(coords[0], coords[1], meeting_timestamp)
# Make API request here and store the responseInterpret API Response
For each location, you will get a response containing information like this:
{
"timezone": {
"name": "America/New_York",
"now_in_dst": 0,
"offset_sec": -18000,
"short_name": "EST",
"full_name": "Eastern Standard Time"
}
}name: IANA time zone identifiernow_in_dst: Indicates if Daylight Saving Time is in effect (1) or not (0)offset_sec: Offset from UTC in secondsshort_name: Abbreviated time zone namefull_name: Full time zone name
Convert Meeting Time
Calculate the converted meeting time for each location using the offset provided in the API response.
Present the Results
Display the original meeting time and the converted meeting times for each location.
Example Code
Here's a more comprehensive example in PHP and Python:
<?php
$access_token = "YOUR_ACCESS_TOKEN"; // Replace with your actual access token
$base_url = "https://us1.locationiq.com/v1/timezone?key=" . $access_token . "&lat=%s&lon=%s×tamp=%s";
$meeting_time_ny = new DateTime("2024-11-14 11:00:00", new DateTimeZone("America/New_York"));
$meeting_timestamp = $meeting_time_ny->getTimestamp();
$locations = [
"New York" => [40.7128, -74.0060],
"San Francisco" => [37.7749, -122.4194],
"London" => [51.5074, -0.1278],
"Cape Town" => [-33.9249, 18.4241],
"Singapore" => [1.3521, 103.8198],
"Tokyo" => [35.6762, 139.6503]
];
$results = [];
foreach ($locations as $city => $coords) {
$url = sprintf($base_url, $coords[0], $coords[1], $meeting_timestamp);
$response = file_get_contents($url);
if ($response !== false) {
$timezone_info = json_decode($response, true)["timezone"];
$offset = $timezone_info["offset_sec"];
$local_time = clone $meeting_time_ny;
$local_time->modify(sprintf("%+d seconds", $offset + 18000)); // 18000 is NY's offset from UTC
$results[$city] = [
"time" => $local_time->format("g:i A"),
"date" => $local_time->format("F j, Y"),
"timezone" => $timezone_info["full_name"]
];
} else {
echo "Failed to retrieve timezone information for $city, " . error_get_last()['message'] . "\n";
}
}
echo "Meeting time in New York: " . $meeting_time_ny->format("g:i A, F j, Y") . "\n";
foreach ($results as $city => $info) {
echo "Meeting time in $city: {$info['time']}, {$info['date']} ({$info['timezone']})\n";
}This script will output the meeting times for all locations, accounting for their specific timezone offsets on the given date.
Remember to replace YOUR_ACCESS_TOKEN with your actual LocationIQ API access token.