Skip to content
🛠️ToolsShed

Julian Date Converter

Convert between Gregorian calendar dates and Julian Day Numbers.

About Julian Day Number

Julian Day Number (JDN) is a continuous count of days since January 1, 4713 BCE. It eliminates confusion from different calendar systems and is widely used in astronomy for precise date and time calculations.

About this tool

The Julian Day Number (JDN) is a continuous count of days since January 1, 4713 BCE, widely used in astronomy, satellite calculations, and historical dating. Unlike the familiar Gregorian calendar, which cycles through months and years, the JDN provides a single, unambiguous number for any given date—making it invaluable for precise astronomical observations and calculations that span centuries without confusion over calendar reforms or regional date conventions.

To use this converter, simply enter either a Gregorian date (month, day, and year) to get its corresponding Julian Day Number, or enter a JDN to convert it back to a standard calendar date. The tool instantly calculates the conversion using the well-established astronomical formula, useful for anyone working with historical records, astronomical data, or software that requires a universal date reference system.

Frequently Asked Questions

Code Implementation

def gregorian_to_jdn(year: int, month: int, day: int) -> float:
    """Convert Gregorian date to Julian Day Number (Meeus algorithm)."""
    if month <= 2:
        year -= 1
        month += 12
    A = year // 100
    B = 2 - A + A // 4
    return int(365.25 * (year + 4716)) + int(30.6001 * (month + 1)) + day + B - 1524.5

def jdn_to_gregorian(jdn: float) -> tuple[int, int, int]:
    """Convert Julian Day Number to Gregorian date (Meeus algorithm)."""
    jdn = jdn + 0.5
    Z = int(jdn)
    if Z < 2299161:
        A = Z
    else:
        alpha = int((Z - 1867216.25) / 36524.25)
        A = Z + 1 + alpha - alpha // 4
    B = A + 1524
    C = int((B - 122.1) / 365.25)
    D = int(365.25 * C)
    E = int((B - D) / 30.6001)
    day = B - D - int(30.6001 * E)
    month = E - 1 if E < 14 else E - 13
    year = C - 4716 if month > 2 else C - 4715
    return year, month, day

jdn = gregorian_to_jdn(2024, 3, 15)
print(f"2024-03-15 → JDN: {jdn}")
y, m, d = jdn_to_gregorian(jdn)
print(f"JDN {jdn} → {y}-{m:02d}-{d:02d}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.