I Built a Better World Time API
Sleeyax

Sleeyax @sleeyax

Location:
Belgium
Joined:
Sep 14, 2024

I Built a Better World Time API

Publish Date: Aug 13
0 0

Have you ever needed to get the current time or timezone for a specific timezone or IP address, only to find that the available APIs are unreliable, outdated, or closed source? I did - and I decided to build a better solution.

Why Build a New World Time API?

The original worldtimeapi.org is a great idea, but it’s had its share of downtime and data issues. Other commercial APIs are often closed source, limited in features, or don’t offer plain text responses. I wanted something that was:

  • Fast and reliable
  • Open source
  • Up-to-date
  • Easy to use
  • Compatible with the World Time API

Introducing: timeapi.world

This project is a drop-in replacement for worldtimeapi.org, built with TypeScript and Cloudflare Workers for speed and scalability. It’s open source and free to use (currently up to 20,000 requests a month, commercial plans are available if you need more).

Key features:

  • 🚀 High performance (Cloudflare Workers)
  • 🟢 Reliable (serverless, global edge network)
  • 📅 Frequently updated (IANA timezone + MaxMind GeoIP with automated updates)
  • 📝 JSON & plain text responses
  • 🌍 Geo IP support
  • 🔄 Backwards compatible with worldtimeapi.org
  • 👐 Open source
  • 🧑‍💻 Swagger/OpenAPI docs

API Endpoints

The API follows the World Time API spec:

Timezone Endpoints

  • GET /api/timezone – List all available timezones (JSON)
  • GET /api/timezone.txt – List all available timezones (plain text)
  • GET /api/timezone/{area} – List timezones for a specific area
  • GET /api/timezone/{area}/{location} – Get current time for a location
  • GET /api/timezone/{area}/{location}/{region} – Get current time for a region

IP-based Endpoints

  • GET /api/ip – Get time based on client IP
  • GET /api/ip/{ipv4} – Get time for a specific IP

All endpoints support both JSON and plain text (just add .txt).

Example Responses

JSON:

{
  "utc_offset": "-04:00",
  "timezone": "America/New_York",
  "day_of_week": 6,
  "day_of_year": 214,
  "datetime": "2025-08-02T13:02:11.703-04:00",
  "utc_datetime": "2025-08-02T17:02:11.703+00:00",
  "unixtime": 1754154131,
  "raw_offset": -18000,
  "week_number": 31,
  "dst": true,
  "abbreviation": "EDT",
  "dst_offset": 3600,
  "dst_from": "2025-03-09T07:00:00+00:00",
  "dst_until": "2025-11-02T06:00:00+00:00",
  "client_ip": "127.0.0.1"
}
Enter fullscreen mode Exit fullscreen mode

Plain Text:

utc_offset: -04:00
timezone: America/New_York
day_of_week: 6
day_of_year: 214
datetime: 2025-08-02T13:02:51.390-04:00
utc_datetime: 2025-08-02T17:02:51.390+00:00
unixtime: 1754154171
raw_offset: -18000
week_number: 31
dst: true
abbreviation: EDT
dst_offset: 3600
dst_from: 2025-03-09T07:00:00+00:00
dst_until: 2025-11-02T06:00:00+00:00
client_ip: 127.0.0.1
Enter fullscreen mode Exit fullscreen mode

Data Sources

Both are industry standards and updated regularly using automation scripts.

How It Works

The API is built with:

  • TypeScript for type safety
  • Hono web framework for performance
  • Cloudflare Workers for global edge deployment
  • Cloudflare D1 for database storage

All endpoints handle both JSON and plain text, with proper error handling and CORS support.

Get Started

Check it out at https://timeapi.world/

Let’s make time APIs better for everyone.


Thanks for reading! If you enjoyed reading my content, follow me on X to stay in the loop ❤️.

Comments 0 total

    Add comment