Moon Cycle Function function moon_cycle($time) { // calcuates where a day is in moon's cycle // // input: time in seconds since epoch // ouput: 0 to <2 where: // new moon = 0, waxing moon = .5, // full moon = 1, waining moon = 1.5 // requires: none // based on: http://www.voidware.com/moon_phase.htm // and also: http://mikesmith.com/blog.html $year = date('Y', $time); $month = date('m', $time); $day = date('d', $time); $c = $e = $jd = $b = 0; if ($month < 3) { $year--; $month += 12; } ++$month; $c = 365.25 * $year; // avg days per year $e = 30.6 * $month; // avg days per month $jd = $c + $e + $day - 694039.09; // jd is total days elapsed $jd /= 29.5305882; // divide by the moon cycle $b = (int) $jd; // int(jd) -> b, take integer part of jd $jd -= $b; // subtract integer part to leave return $jd * 2; }
Leave a Reply Cancel replyYour email address will not be published. Required fields are marked *Comment * Name * Email * Website Save my name, email, and website in this browser for the next time I comment. Δ