The moon phase tonight tool renders a live lunar disc, shows the exact illumination percentage, marks where today falls on the 29.53-day synodic cycle, and lists when the next four principal phases occur — all computed instantly in your browser without any network call.
How it works
The calculation follows Jean Meeus Astronomical Algorithms (2nd edition), the standard reference for amateur and professional planetary computation.
Step 1 — Julian Date. The selected date (noon UTC) is converted to a Julian Date (JD) — a continuous count of days from 1 January 4713 BC used in astronomy to avoid calendar-system complications.
Step 2 — Moon age. The elapsed days since the reference new moon of 6 January 2000 at 18:14 UTC (JD 2451550.1) are divided by the mean synodic month of 29.530589 days. The fractional remainder is the Moon’s age in the current cycle (0 = new, 14.76 = full, 29.53 = next new).
Step 3 — Illuminated fraction. The fraction through the cycle maps to an illumination via:
illumination = (1 - cos(2 * pi * age / 29.53)) / 2
This follows from the geometry of the Sun–Earth–Moon angle: the lit fraction grows smoothly from 0% at new moon through 50% at the quarters to 100% at full moon.
Step 4 — Phase name. The eight named phases are assigned by dividing the cycle into eighths. The index round(fraction * 8) mod 8 selects the correct label.
Step 5 — Disc rendering. The SVG moon disc draws a right semicircle (the lit side) and closes it with an elliptical terminator whose horizontal semi-axis is R * (1 - 2 * illumination). A positive terminator semi-axis produces a crescent; a negative one produces a gibbous shape. For waning phases the disc is reflected horizontally so the lit side appears on the left.
Step 6 — Earth–Moon distance. A truncated Meeus Chapter 47 series calculates the approximate geocentric distance in kilometres using the Moon’s mean anomaly, the Sun’s mean anomaly, mean elongation, and argument of latitude.
Worked example
On a day when the Moon’s age is 19.5 days (roughly five days after full moon):
- Fraction through cycle: 19.5 ÷ 29.53 ≈ 0.66
- Illumination: (1 - cos(2π × 0.66)) / 2 ≈ 0.77 → 77% lit
- Phase index: round(0.66 × 8) = round(5.28) = 5 → Waning Gibbous
- The disc shows a large lit area on the left (waning), with a thin dark crescent on the right
| Age (days) | Fraction | Phase | Illumination |
|---|---|---|---|
| 0 | 0.00 | New Moon | 0% |
| 3.7 | 0.13 | Waxing Crescent | 15% |
| 7.4 | 0.25 | First Quarter | 50% |
| 11.1 | 0.38 | Waxing Gibbous | 85% |
| 14.8 | 0.50 | Full Moon | 100% |
| 18.4 | 0.62 | Waning Gibbous | 85% |
| 22.1 | 0.75 | Last Quarter | 50% |
| 25.8 | 0.87 | Waning Crescent | 15% |
Formula note
The illumination formula uses the phase angle between the Sun, Earth and Moon. At new moon the phase angle is 0° (Moon between Sun and Earth, far side lit); at full moon it is 180° (Earth between Sun and Moon, near side fully lit). The cosine function maps this continuously: illumination = (1 - cos(phase_angle)) / 2, where phase_angle = 2 * pi * fraction. The Meeus harmonic corrections to the epoch reduce the typical error from around ±1 day (mean-synodic-month-only) down to a few hours.