Moon, a php script
What is the current lunar phase? Let's ask it to my website.

This is a small script that can be used to calculate moon phases. It's the porting to php of some code lines written in C. I don't remember where I've found the original script, so I can't report the original coder. Sorry. Returning values:

function GetMoon ($y, $m, $d)
{
    $c = 0;
    $e = 0;
    $jd = 0.0;
    $b = 0;

    if ($m < 3) {
        $y = $y -1;
        $m = $m + 12;
    }
    $m = $m + 1;
    $c = 365.25 * $y;
    $e = 30.6 * $m;
    $jd = $c + $e + $d-694039.09;  /* jd is total days elapsed */
    $jd /= 29.53; /* divide by the moon cycle (29.53 days) */
    $b = floor(jd); /* int(jd) -> b, take integer part of jd */
    $jd = $jd - $b;	/* subtract integer part to leave fractional part of original jd */
    $b = round($jd * 8); /* scale fraction from 0-8 and round by adding 0.5 */
    $b = $b & 7; /* 0 and 8 are the same so turn 8 into 0 */
    return $b;
}

link Wikipedia: Lunar phase
link Wikipedia: Blue moon
aggiornamento (ultimo agg. 20/12/12)
Licenza Creative Commons

Il contenuto di questo sito è distribuito con Licenza Creative Commons Attribuzione - Condividi allo stesso modo 4.0 Internazionale.

Privacy policy

Graphics by GIMP