World Time API
The World Time API provides the current date and time for any city, latitude/longitude coordinates or timezone in the world.
From 7,436 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 344ms | 380ms | 414ms | 629ms | 1198ms |
Didn't find what you were looking for? Suggest an improvement
/v1/worldtime GET
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:
timezonelatandloncity(optionally withstateand/orcountry)
timezoneoptionalTimezone name (e.g.
Europe/London).latoptional premiumLatitude of desired location.
lonoptional premiumLongitude of desired location.
cityoptional premiumCity name.
stateoptional premiumUS state (for United States cities only).
countryoptional premiumCountry name.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON object with the following fields or an error if the request is unsuccessful.
timezoneIANA timezone identifier (for example
Europe/London).datetimeLocal date and time string (YYYY-MM-DD HH:MM:SS).
dateCurrent date in YYYY-MM-DD format.
yearCurrent year as a 4-digit string.
monthCurrent month as a 2-digit string between
01and12(inclusive).dayCurrent day of the month as a 2-digit string between
01and31(inclusive).hourCurrent hour in 24-hour format as a 2-digit string between
00and23(inclusive).minuteCurrent minute as a 2-digit string between
00and59(inclusive).secondCurrent second as a 2-digit string between
00and59(inclusive).day_of_weekName of the day of the week (for example
Sunday).
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/worldtime?city=LondonHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
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
Can I use the World Time API for commercial purposes?
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.How do I get an API key and start using the World Time API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
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.What happens if a request to the World Time API fails?
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.How can I look up the current time for a specific location?
You can query by IANAtimezonename (e.g.Europe/London), bylatandloncoordinates, or bycity(optionally narrowed withstateandcountry). If you only have coordinates or a place name, our Geocoding API can resolve them first.Which parameters require a premium subscription?
Thetimezoneparameter is available on all plans, but querying bylat/lon,city,state, orcountryrequires a premium subscription, as noted on each parameter; see our pricing page for details.What fields does the response include?
Each response returns thetimezone, a fulldatetimestring (YYYY-MM-DD HH:MM:SS), and the individualdate,year,month,day,hour,minute,second, andday_of_weekfields; if a request fails you will instead receive an error.How does this differ from the Timezone 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.