Daily Life

Hijri Calendar Converter – Tutorial

On this page, you can find the logic, usage, and important details of the Hijri Calendar Converter calculator.

Page
Tutorial
Quick jump
Follow the headings below
Hint
Results are for informational purposes

Hijri Calendar Converter — Detailed Guide (Gregorian → Hijri)

This page explains step by step how a Gregorian (Miladi) date is converted to a Hijri date. The calculator's approach: convert the Gregorian date to a common "day count" system, then derive the Hijri year/month/day from that count.


1) What is the Hijri Calendar?

The Hijri calendar is a lunar calendar based on the phases of the Moon. The Gregorian calendar is a solar calendar based on the Earth's orbit around the Sun.

  • Gregorian year ≈ 365.2422 days (solar year)
  • Hijri year ≈ 354 or 355 days (lunar year)
  • So the Hijri year falls about 10–11 days earlier each Gregorian year.

Important: Hijri months can be observational (based on crescent moon sighting), so results may differ by 1 day between countries. This calculator uses the astronomical/calculated method.


2) Why Can't We Convert Directly? (The core idea)

Gregorian months have 28–31 days. Hijri months have 29 or 30 days. Since the two calendars follow different logic, converting "2025-12-28 = which Hijri day" requires a common bridge between the two systems.

That bridge is: Julian Day Number.


3) What is the Julian Day Number?

The Julian Day is a system that converts any date into a sequential day count. Instead of dealing with complex month/year structures, it answers: "How many days have passed since the beginning?"

  • Each day = +1
  • Calculating differences between dates becomes trivial
  • Serves as a common language for Gregorian ↔ Hijri conversions

The calculator first produces a Julian Day from the Gregorian date:

Gregorian Date → Julian Day → Hijri Date


4) How Does This Calculator Work?

4.1 Parses the Gregorian date

  • day, month, year

Then checks if the year is after 1583. The Gregorian calendar was introduced around 1582, so algorithms are reliable only after that point.

4.2 Calculates the Julian Day

  • Sums the days in the year (365.25 approximation)
  • Adds the month contribution (30.6001 approximation)
  • Applies the Gregorian correction (century correction)
  • Result: julianDay

4.3 Subtracts the Hijri epoch

A fixed "start day" constant for the Hijri calendar:

iEpoch = 1948439.5

This references the Julian Day of the Hijri calendar's start (the Hijra). Then:

iDay = julianDay - iEpoch

"How many days have passed since the Hijri beginning to this Gregorian date?"


5) How is the Hijri Year Found? (30-year cycle)

The Hijri calendar has a leap year system based on a 30-year cycle. Total days in 30 Hijri years:

10,631 days

  • cyc = iDay / 10631 — how many complete 30-year cycles have passed
  • rem — remaining days within the current cycle

Then the remaining days are divided by the approximate Hijri year length (354.36667):

iYear ≈ rem / 354.36667

This is a calculated approximation. Real-world institutions (like Diyanet) may also use observation/astronomy tables, which can result in 1-day differences.


6) How Are the Hijri Month and Day Found?

6.1 Hijri months alternate between 29 and 30 days

  • 30, 29, 30, 29, ... alternating
  • The last month (Dhu al-Hijjah) may have 30 days in leap years

6.2 Leap year check

Some Hijri years have 355 days. The check:

(iYear * 11 + 14) % 30 < 11 → leap year

  • If leap year: monthLengths[11] = 30 (Dhu al-Hijjah = 30 days)

6.3 Finding month and day by subtracting

"rem" represents the day within the year. Month lengths are subtracted one by one:

  • If rem ≤ first month length: we're in month 1
  • Otherwise: rem -= that month's length, move to next month

Result: hMonth (which month) and hDay (day of month).

6.4 Why is there a "hDay = 0" correction?

At exact boundary cases, the remaining days can appear as 0. Since there's no "day 0" in a calendar, the code shifts back to the previous month's last day.


7) Hijri Month Names

  • 1 Muharram
  • 2 Safar
  • 3 Rabi al-Awwal
  • 4 Rabi al-Thani
  • 5 Jumada al-Awwal
  • 6 Jumada al-Thani
  • 7 Rajab
  • 8 Sha'ban
  • 9 Ramadan
  • 10 Shawwal
  • 11 Dhu al-Qi'dah
  • 12 Dhu al-Hijjah

8) Special Day Detection (Ramadan / Eid / Islamic New Year)

  • Month of Ramadan: hMonth = 9
  • Start of Eid al-Fitr: hMonth = 10 and hDay = 1
  • Start of Eid al-Adha: hMonth = 12 and hDay = 10
  • Islamic New Year: hMonth = 1 and hDay = 1

Note: Official holiday declarations may differ by 1 day between countries/institutions. This tool uses the calculated method and is for informational purposes only.


9) What Does the Result Table Show?

The table breaks the date into its components for easy verification:

  • Day: hDay
  • Month: Hijri month name
  • Year: finalHYear
  • Gregorian Reference: selected date

10) Why Can Results Differ by 1 Day?

  • Observational (crescent): month starts when the crescent moon is sighted
  • Calculated (astronomical): month starts based on pre-calculated tables

Institutions like Diyanet and Umm al-Qura use specific astronomical criteria. Different criteria can shift some dates by 1 day.


11) How to Use This Calculator Accurately

  1. Select a Gregorian date (e.g., 2025-12-28)
  2. Read the Hijri date result
  3. Check for special day labels (Ramadan, Eid, etc.)
  4. For official religious dates, always refer to your local institution's calendar (e.g., Diyanet)

Warning: This tool is for informational purposes only. For official announcements and religious observances, always use the calendar published by the relevant institution.