******************************************************************************
SIMPLE LUNAR PHASE ANGLE TABLE FUNCTION DEMO
Built around the NASA/JPL Horizons API
PHP Program by Jay Tanner - 2025
This program is based on a custom function to generate a simple lunar phase
table over a given range from a single date to multiple dates spanning any
general interval at any given time step size.
It is called the 'simple' lunar phase because it is geocentric and based on
the difference between the ecliptical longitudes of the moon and sun at the
same moment and excludes the tiny effects of librations, but still results
in a good enough lunar phase approximation for most practical purposes and
general small-scale graphical simulations.
PhaseTable = Lunar_Phase_Table (StartDateTimeStr, StopDateTimeStr, StepSize,
TimeZone, DaySumYN, HeaderYN)
*********************************************************
Geocentric Lunar Phase Table
Time Zone = UT-05:00 (dJDate = -0.2083333333)
Day/Summ Time = No
Table Header = Yes
START Date/Time = 2025-Jun-01 00:00:00 (Standard Time)
STOP Date/Time = 2025-Jul-01 00:00:00
Step Size = 1 day
=========================================================
Loc_Date Loc_Time Cnst Julian_Date_UT Phase_Ang
============ ======== ==== ================= =========
2025-Jun-01 00:00:00 Leo 2460827.708333333 67.24956
2025-Jun-02 00:00:00 Leo 2460828.708333333 79.12369
2025-Jun-03 00:00:00 Leo 2460829.708333333 90.62274
2025-Jun-04 00:00:00 Vir 2460830.708333333 101.83037
2025-Jun-05 00:00:00 Vir 2460831.708333333 112.83530
2025-Jun-06 00:00:00 Vir 2460832.708333333 123.72355
2025-Jun-07 00:00:00 Vir 2460833.708333333 134.57315
2025-Jun-08 00:00:00 Lib 2460834.708333333 145.45065
2025-Jun-09 00:00:00 Lib 2460835.708333333 156.40918
2025-Jun-10 00:00:00 Sco 2460836.708333333 167.48789
2025-Jun-11 00:00:00 Oph 2460837.708333333 178.71282
2025-Jun-12 00:00:00 Sgr 2460838.708333333 190.09942
2025-Jun-13 00:00:00 Sgr 2460839.708333333 201.65632
2025-Jun-14 00:00:00 Sgr 2460840.708333333 213.39004
2025-Jun-15 00:00:00 Cap 2460841.708333333 225.30952
2025-Jun-16 00:00:00 Cap 2460842.708333333 237.42944
2025-Jun-17 00:00:00 Aqr 2460843.708333333 249.77123
2025-Jun-18 00:00:00 Aqr 2460844.708333333 262.36072
2025-Jun-19 00:00:00 Psc 2460845.708333333 275.22223
2025-Jun-20 00:00:00 Psc 2460846.708333333 288.36917
2025-Jun-21 00:00:00 Ari 2460847.708333333 301.79260
2025-Jun-22 00:00:00 Ari 2460848.708333333 315.45051
2025-Jun-23 00:00:00 Tau 2460849.708333333 329.26214
2025-Jun-24 00:00:00 Tau 2460850.708333333 343.11153
2025-Jun-25 00:00:00 Aur 2460851.708333333 356.86198
2025-Jun-26 00:00:00 Gem 2460852.708333333 10.37853
2025-Jun-27 00:00:00 Cnc 2460853.708333333 23.55086
2025-Jun-28 00:00:00 Cnc 2460854.708333333 36.30937
2025-Jun-29 00:00:00 Leo 2460855.708333333 48.63067
2025-Jun-30 00:00:00 Leo 2460856.708333333 60.53360
2025-Jul-01 00:00:00 Leo 2460857.708333333 72.06977
*********************************************************
Table to help visualize the lunar phase angles:
PhaseAng Description
-------- -----------------
0° New Moon
45 Waxing Crescent
90 First Quarter
135 Waxing Gibbous
180 Full Moon
225 Waning Gibbous
270 Last Quarter
315 Waning Crescent
360/0 New Moon
******************************************************************************
To compute the simple geocentric lunar phase angle (0 to 360 deg) based on
the ecliptical longitudes of the moon and sun at the same moment also in the
the range from 0 to 360 degrees:
Let:
PhaseAng = Simple lunar phase angle (0 to 360 deg) based on the
difference between the ecliptical longitudes.
Given:
Lm = Geocentric ecliptical longitude of the moon (0 to 360 deg).
Ls = Geocentric ecliptical longitude of the sun (0 to 360 deg).
Then, the simple phase angle may be found
by one of the following simple algorithms:
----------------------------------------
w = 360 - Lm + Ls
if (w > 360) then w = w - 360
PhaseAng = 360 - w
----------------------------------------
Or, the alternate equivalent:
w = 360 - Lm + Ls
PhaseAng = 360 − (w −= (w > 360)? 360:0)
******************************************************************************