islamicdate.today does not run a public API of its own. Every Islamic date on the site comes from the free Aladhan calendar service, using the Umm al-Qura method, plus one simple rule for South Asia. This guide shows you how to get exactly the same dates in your own app or website.
Nothing here needs an account or a key. You need two endpoints, a one-day shift and a cache.
What the site offers developers
There is no JSON endpoint on islamicdate.today for dates, and we do not promise one. What we publish is the method: the source we use, the parameters, the regional rule and the checks we run. You are welcome to copy it.
The two endpoints you need
Aladhan's public API converts in both directions. Add calendarMethod=UAQ to every request to get the Umm al-Qura calendar, which is the worldwide date the site shows.
| Task | Endpoint | Returns |
|---|---|---|
| One Gregorian day to Hijri | /v1/gToH/DD-MM-YYYY?calendarMethod=UAQ | One object with hijri and gregorian |
| One Hijri day to Gregorian | /v1/hToG/DD-MM-YYYY?calendarMethod=UAQ | One object with hijri and gregorian |
| A whole Gregorian month | /v1/gToHCalendar/MONTH/YEAR?calendarMethod=UAQ | An array, one entry per day |
| A whole Hijri month | /v1/hToGCalendar/MONTH/YEAR?calendarMethod=UAQ | An array, one entry per day |
All four live under https://api.aladhan.com. The site itself calls the two month endpoints, because one request then covers 29 to 31 days and is easy to cache. The single-day endpoints are simpler if you only need today.
A successful reply has "code": 200. Inside data.hijri you get day, month.number, month.en, month.ar and year, and dates come as DD-MM-YYYY strings. Month names in month.en carry accents, for example Ramaḍān, so map month numbers to your own names if you want plain spellings.
The South Asia rule
Pakistan, India and Bangladesh begin each month by local moon sighting, usually one day after Saudi Arabia. The site models that with a fixed one-day shift, in both directions.
Gregorian to Hijri
For South Asia, subtract one day from the Gregorian date, then ask for its Umm al-Qura date. On 9 Feb 2027 you ask for 8 Feb 2027 and get 1 Ramadan 1448.
Hijri to Gregorian
Ask for the Umm al-Qura Gregorian date, then add one day. 1 Ramadan 1448 is 8 Feb 2027 in the calendar, so it is 9 Feb 2027 in Pakistan and India.
Pick the right "today"
Work out today in the user's time zone first. The site uses Pakistan time (Asia/Karachi) by default, so its date turns over at midnight there.
This rule matched the announced first fast of Ramadan in Pakistan and India in 1445, 1446 and 1447 AH. The evidence and its limits are on how we determine the Islamic date.
JavaScript example
This runs in a browser, in Node 18 or later, or in a Cloudflare Worker. It returns both dates for one Gregorian day. Run it as an ES module, since it uses top-level await.
const BASE = 'https://api.aladhan.com/v1';
// 'YYYY-MM-DD' plus n days, done in UTC so time zones never shift it
function addDays(iso, n) {
const d = new Date(iso + 'T00:00:00Z');
d.setUTCDate(d.getUTCDate() + n);
return d.toISOString().slice(0, 10);
}
const toDmy = (iso) => iso.split('-').reverse().join('-');
async function hijriFor(iso, region = 'south-asia') {
const day = region === 'south-asia' ? addDays(iso, -1) : iso;
const res = await fetch(`${BASE}/gToH/${toDmy(day)}?calendarMethod=UAQ`);
const json = await res.json();
if (json.code !== 200) throw new Error('Aladhan error');
const h = json.data.hijri;
return `${+h.day} ${h.month.en} ${h.year}`;
}
// Today in Pakistan time, as YYYY-MM-DD
const today = new Intl.DateTimeFormat('en-CA', { timeZone: 'Asia/Karachi' }).format(new Date());
console.log('Pakistan/India:', await hijriFor(today));
console.log('Worldwide:', await hijriFor(today, 'world'));
Going the other way, call /hToG/01-09-1448?calendarMethod=UAQ, read data.gregorian.date, turn it into YYYY-MM-DD and pass it through addDays(iso, 1) for South Asia.
PHP example
The same logic in plain PHP 7.4 or later, with no libraries.
<?php
function hijri_for(string $iso, bool $southAsia = true): ?string {
$d = new DateTime($iso, new DateTimeZone('UTC'));
if ($southAsia) {
$d->modify('-1 day');
}
$url = 'https://api.aladhan.com/v1/gToH/' . $d->format('d-m-Y') . '?calendarMethod=UAQ';
$ctx = stream_context_create(['http' => ['timeout' => 8]]);
$raw = @file_get_contents($url, false, $ctx);
$json = $raw ? json_decode($raw, true) : null;
if (($json['code'] ?? 0) !== 200) {
return null;
}
$h = $json['data']['hijri'];
return (int) $h['day'] . ' ' . $h['month']['en'] . ' ' . $h['year'];
}
$today = (new DateTime('now', new DateTimeZone('Asia/Karachi')))->format('Y-m-d');
echo 'Pakistan/India: ' . hijri_for($today) . "\n";
echo 'Worldwide: ' . hijri_for($today, false) . "\n";
If your host blocks file_get_contents for URLs, use cURL with the same URL and an 8-second timeout.
Caching advice
A Islamic date for a given Gregorian day almost never changes, so you should not call the API on every page view. These are the rules the site follows.
Fetch a month at a time
One call to gToHCalendar covers a whole Gregorian month. Store it keyed by year and month.
Long cache for the past
Months that have ended do not change. The site keeps them for 30 days; you can keep them longer.
Daily refresh for now
The current and future months can be adjusted, so refresh them once a day. Hijri months are cached for a week.
Plan for an outage
Set a timeout (the site uses 8 seconds) and have a fallback. Do not cache a fallback result as if it were real data.
Also check that a month reply is complete before you store it. The site only caches a Gregorian month with at least 28 days in it and a Hijri month with at least 29.
An offline fallback
When the API cannot be reached, the site falls back to the tabular Islamic calendar: a fixed arithmetic cycle of 30 years, with 11 leap years of 355 days. It needs no network and is a few lines of integer maths, but it does not follow the moon and can be a day away from Umm al-Qura.
Show the uncertainty
If your app is running on the fallback, say so, or show the date as approximate. Never use a fallback date to tell people when Ramadan or Eid begins.
Common mistakes
- Leaving out
calendarMethod=UAQ. Aladhan supports several calendar methods, and its default may not be Umm al-Qura, so you can be a day out from Saudi Arabia. - Shifting the wrong way. For South Asia you subtract a day before Gregorian to Hijri, and add a day after Hijri to Gregorian.
- Using the server's time zone. A server in Europe still thinks it is yesterday after midnight in Pakistan. Compute "today" in the user's zone.
- Mixing up date formats. Aladhan paths use
DD-MM-YYYY, not ISOYYYY-MM-DD. - Treating the result as an announcement. Both dates are calculated. For Ramadan, Eid and the Day of Arafah, the local sighting committee decides.
Attribution and fair use
Credit Aladhan as the source of the Umm al-Qura data in your app's about screen or documentation, and read its current terms on aladhan.com before you ship. Cache your results so you send it as few requests as possible; it is a free service shared by many developers.
If you also describe the South Asia rule, a link to this page or to our method page helps your users understand why two dates exist. Our GitHub profile has a public repository about Islamic date data.
Check your results
Compare a few days from your code with the Islamic date converter, which shows both regional dates for any day from 1938 to 2076. The monthly Hijri calendar is handy for checking month starts. Good test cases are 11 and 12 March 2024, 1 and 2 March 2025, and 18 and 19 February 2026, the first fasts of recent Ramadans in Saudi Arabia and South Asia.
Found a difference you cannot explain? Send us the details and we will look.