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.

1. 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

2. 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&timestamp=UNIX_TIMESTAMP
  • Replace YOUR_ACCESS_TOKEN with your actual API access token
  • LATITUDE and LONGITUDE are the coordinates of the location
  • UNIX_TIMESTAMP is the Unix epoch time for the desired moment (optional, defaults to current time if omitted)

3. 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={}&timestamp={}"
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 response

4. Interpret 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 identifier
  • now_in_dst: Indicates if Daylight Saving Time is in effect (1) or not (0)
  • offset_sec: Offset from UTC in seconds
  • short_name: Abbreviated time zone name
  • full_name: Full time zone name

5. Convert Meeting Time

Calculate the converted meeting time for each location using the offset provided in the API response.

6. 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&timestamp=%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";
}
import urllib.request
import json
from datetime import datetime
from zoneinfo import ZoneInfo

access_token = "YOUR_ACCESS_TOKEN"  # Replace with your actual access token
base_url = f"https://us1.locationiq.com/v1/timezone?key={access_token}&lat={{}}}&lon={{}}&timestamp={{}}"

# Define the meeting time in New York (EST)
meeting_time_ny = datetime(2024, 11, 14, 11, 0, tzinfo=ZoneInfo("America/New_York"))
meeting_timestamp = int(meeting_time_ny.timestamp())

# Dictionary of locations with their coordinates
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),
    "Unknown Location": (35.6892, 51.3890)  # Coordinates for Tehran, intentionally unlabeled
}

results = {}

def get_timezone_info(city, coords):
    url = base_url.format(coords[0], coords[1], meeting_timestamp)
    try:
        with urllib.request.urlopen(url) as response:
            data = json.loads(response.read().decode())
            timezone_info = data["timezone"]
            tz = ZoneInfo(timezone_info["name"])
            local_time = meeting_time_ny.astimezone(tz)
            results[city] = {
                "time": local_time.strftime("%I:%M %p"),
                "date": local_time.strftime("%B %d, %Y"),
                "timezone": timezone_info["full_name"],
                "is_dst": "Yes" if timezone_info["now_in_dst"] == 1 else "No"
            }
    except urllib.error.URLError as e:
        print(f"Failed to retrieve timezone information for {city}: {str(e)}")

def print_results():
    print(f"Meeting time in New York: {meeting_time_ny.strftime('%I:%M %p, %B %d, %Y %Z')}")
    for city, info in results.items():
        print(f"Meeting time in {city}: {info['time']}, {info['date']}")
        print(f"  Timezone: {info['timezone']}")
        print(f"  Daylight Saving Time in effect: {info['is_dst']}")
        print()

# Fetch timezone information for all locations
for city, coords in locations.items():
    get_timezone_info(city, coords)

# Print results
print_results()

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.