Timezone API by Country — Full Guide 2026
Timezone data is one of those things developers underestimate until they get a bug report at 2am from a user in a different country. Here's how to handle it properly.
Why Timezone Data Matters
- Scheduling features (meeting bookings, reminders, cron jobs)
- Displaying "last updated at" timestamps in the user's local time
- Date pickers that need to know if a date is in the past for a given region
- Calculating business hours across multiple locations
Getting Timezone from a Country Code
ApogeoAPI returns a timezones array in every country response:
const res = await fetch('https://api.apogeoapi.com/v1/countries/US', {
headers: { 'X-API-Key': 'your_key' }
});
const country = await res.json();
console.log(country.timezones);
// ['America/New_York', 'America/Chicago', 'America/Denver',
// 'America/Los_Angeles', 'America/Anchorage', 'Pacific/Honolulu']
Getting Timezone from IP (More Accurate)
For individual user sessions, IP geolocation gives you a single specific timezone — more accurate than a country-level list:
const res = await fetch('https://api.apogeoapi.com/v1/geolocate/USER_IP', {
headers: { 'X-API-Key': 'your_key' }
});
const geo = await res.json();
console.log(geo.timezone); // 'America/Los_Angeles'
Countries with Multiple Timezones
The US has 6, Russia has 11, and Australia has 5. When your app needs to display times for a country rather than a specific user, you'll need to handle the array:
function formatTimeInCountry(date: Date, country: { timezones: string[] }) {
// Use the first timezone as the "primary" one
// Or let the user pick from the list
const tz = country.timezones[0];
return new Intl.DateTimeFormat('en-US', {
timeZone: tz,
dateStyle: 'medium',
timeStyle: 'short',
}).format(date);
}
Converting to User's Timezone in JavaScript
Once you have an IANA timezone string from the API, Intl.DateTimeFormat does the heavy lifting — no libraries needed:
const userTimezone = 'Europe/Berlin'; // from IP geo or country data
const formatter = new Intl.DateTimeFormat('en-US', {
timeZone: userTimezone,
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
});
console.log(formatter.format(new Date())); // "April 1, 2026, 10:30 AM"
Caching Strategy
Timezone data changes very rarely (maybe once a year when a country updates DST rules). Cache aggressively:
- Country timezones: cache for 24 hours minimum, 7 days is fine
- IP-based timezone: cache per IP for 1 hour (users travel, IPs change)
- Store in Redis or localStorage depending on whether it's server-side or client-side
Try ApogeoAPI free
1,000 requests/month forever. 14-day full-access trial. No credit card.
Get your free API key