For developers

Julian Dates in Code

Copy-paste formulas and functions for both kinds of Julian date — the day-of-year code and the astronomical Julian Date — in the tools you actually use. Each snippet is verified against known reference values.

Two conversions, everywhere

Every page covers the same two tasks in its language:

  • Day-of-year (ordinal) Julian date: turn a date into YYYYDDD, YYDDD or the JD Edwards CYYDDD form, and back.
  • Astronomical Julian Date: turn a date and time into JD, JDN and MJD, and back.

Every format for one date

Use these values for July 21, 2026 to test your own code:

FormatValueWhat it is
Day of year202Position in the year, 1–366
YYYYDDD2026202Four-digit year + day of year
YYDDD26202Two-digit year + day of year
YDDD6202Last digit of the year + day of year (MRE, military)
CYYDDD126202JD Edwards: centuries since 1900 + YY + DDD
Julian Day Number2461243Astronomical day count for the date
Julian Date (JD)2461242.5Same count with the time of day (00:00 UTC here)
Modified JD (MJD)61242JD − 2400000.5, starts at midnight

Prefer not to write any code? The on-site converter does both instantly in your browser.

A note on accuracy

The astronomical snippets use the standard algorithm from Jean Meeus and agree on the key anchors: the Unix epoch (JD 2440587.5), the MJD epoch (JD 2400000.5) and J2000.0 (JD 2451545.0). Watch out for time-zone and day-boundary details — the pages flag the common traps in each language.