NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server →

World Time API

The World Time API provides the current date and time for any city, latitude/longitude coordinates or timezone in the world, including UTC offset, Unix timestamp and daylight-saving status. Premium plans add business-day arithmetic and working-hours lookups that account for each country's own weekend, its nationwide public holidays and its official make-up working days.

Online
(4.2)

From 7,436 users

1,700+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
344ms380ms414ms629ms1198ms

Didn't find what you were looking for? Suggest an improvement

https://api.api-ninjas.com/v1/worldtime

Get the current date and time by city/state/country, location coordinates (latitude/longitude), or timezone.

Parameters

One of the following parameter combinations must be provided:

  • timezone
  • lat and lon
  • city (optionally with state and/or country)
  • timezone  optional

    Timezone name (e.g. Europe/London).

  • lat  optional

    Latitude of desired location.

  • lon  optional

    Longitude of desired location.

  • city  optional

    City name.

  • state  optional

    US state (for United States cities only).

  • country  optional

    Country name.

  • at  optional Premium only

    UTC instant to evaluate instead of the current time, formatted as YYYY-MM-DDTHH:MM:SS. Resolves the correct historical or future UTC offset for the location, and adds a dst_transitions field listing the next daylight-saving changes.

  • add_business_days  optional Premium only

    Number of business days to add (or subtract, if negative) from the current date in that location, skipping the country's weekend (for example Friday and Saturday in Saudi Arabia) and its nationwide public holidays. Official make-up working days count as business days. Must be between -3650 and 3650.

  • business_days_between  optional Premium only

    Two dates formatted as YYYY-MM-DD,YYYY-MM-DD. Returns the number of business days from the first date up to (not including) the second, excluding the country's weekend and nationwide public holidays.

  • business_hours  optional Premium only

    Opening hours formatted as HH:MM-HH:MM. Returns whether the location is currently open, along with the next opening and closing times, accounting for the country's weekend and nationwide public holidays.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/worldtime endpoint returns a JSON object with the following fields, or an error if the request is unsuccessful.

  • timezone

    IANA timezone identifier (for example Europe/London).

  • datetime

    Local date and time string (YYYY-MM-DD HH:MM:SS).

  • date

    Current date in YYYY-MM-DD format.

  • year

    Current year as a 4-digit string.

  • month

    Current month as a 2-digit string between 01 and 12 (inclusive).

  • day

    Current day of the month as a 2-digit string between 01 and 31 (inclusive).

  • hour

    Current hour in 24-hour format as a 2-digit string between 00 and 23 (inclusive).

  • minute

    Current minute as a 2-digit string between 00 and 59 (inclusive).

  • second

    Current second as a 2-digit string between 00 and 59 (inclusive).

  • day_of_week

    Name of the day of the week (for example Sunday).

  • utc_offset

    Offset from UTC currently in effect at the location, formatted as +HH:MM or -HH:MM.

  • utc_datetime

    The same instant expressed in UTC, in ISO 8601 format.

  • unixtime

    Unix epoch timestamp in seconds.

  • abbreviation

    Timezone abbreviation currently in effect (for example BST or EST).

  • dst

    true if daylight saving time is currently in effect at the location.

  • day_of_year

    Day of the year as an integer between 1 and 366.

  • week_number

    ISO 8601 week number.

  • business_day_result  Premium only

    Returned when add_business_days is set. Contains start_date, business_days_added, result_date, result_day_of_week, skipped_weekend_days, and skipped_holidays (each with a date and name).

  • business_days_between  Premium only

    Returned when business_days_between is set. Contains start_date, end_date, business_days, weekend_days, and the holidays that fell in the range.

  • business_hours  Premium only

    Returned when business_hours is set. Contains is_open, reason, opens, closes, next_open, and next_close.

  • dst_transitions  Premium only

    The next daylight-saving transitions for the location, each with transition_utc, utc_offset, dst, and abbreviation.

Live Demo

Live demo · no API key required
Query parameters
city
state
country
lat
lon

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/worldtime?city=London
Sample response
{
"timezone": "Europe/London",
"datetime": "2022-09-18 19:16:43",
"date": "2022-09-18",
"year": "2022",
"month": "09",
"day": "18",
"hour": "19",
"minute": "16",
"second": "43",
"day_of_week": "Sunday",
"utc_offset": "+01:00",
"utc_datetime": "2022-09-18T18:16:43+00:00",
"unixtime": 1663528603,
"abbreviation": "BST",
"dst": true,
"day_of_year": 261,
"week_number": 37
}

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/worldtime?city=london" \ -H "X-Api-Key: YOUR_API_KEY"

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.

Frequently Asked Questions

  • Yes, but you must have a premium subscription. Commercial use of the World Time API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.
  • The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.
  • You can query by IANA timezone name (e.g. Europe/London), by lat and lon coordinates, or by city (optionally narrowed with state and country). If you only have coordinates or a place name, our Geocoding API can resolve them first.
  • All location lookups — timezone, lat/lon, city, state and country — are available on every plan, including the free tier. Premium subscriptions add the at parameter for historical and future UTC offsets, plus add_business_days, business_days_between and business_hours for holiday-aware business-day calculations; see our pricing page for details.
  • Each response returns the timezone, a full datetime string (YYYY-MM-DD HH:MM:SS), the individual date, year, month, day, hour, minute, second and day_of_week fields, plus utc_offset, utc_datetime, unixtime, abbreviation, dst, day_of_year and week_number; if a request fails you will instead receive an error.
  • Yes. Premium subscribers can pass add_business_days (for example ?city=London&add_business_days=5) to advance a date by a number of working days, or business_days_between=2026-10-01,2026-10-31 to count them across a range. Both skip weekends and the public holidays of the country the location belongs to, and the response lists exactly which holidays were skipped. Use business_hours=09:00-17:00 to check whether a location is currently open. For the underlying holiday calendar, see the Holidays API.
  • The World Time API returns the live local date and time for a location, while the Timezone API focuses on the timezone metadata itself; you can also resolve city details with the City API.