<?php
/**
* Description: Abschätzung(sic!) der Mondphase
* Author: Jörg Reinholz, fastix Webdesign & Consult, Kassel (Germany) www.fastix.org
* Version 1.0
**/
function FtxMondPhase ($d=false, $m=false, $y=false) {
$periodD = 29.530588;
$periodS = $periodD * 24 * 60 * 60;
$halfPeriod = $periodD/2;
$Period_6 = $periodD/6;
$quarterPeriod = $periodD/4;
$ankerDate = mktime(13,55,18,1,22,1970);
# 22. Januar 1970, 13:55:18 Uhr
$date; $phase; $diff;
if ( false === $d ) { $d = date('j'); }
if ( false === $m ) { $m = date('n'); }
if ( false === $y ) { $d = date('Y'); }
$date = mktime(23,59,59, $m, $d, $y);
$diff = ($date - $ankerDate) / $periodS;
$phase = round ( $periodD * ( $diff - floor($diff) ), 2);
switch ( true ) {
case ( $phase <= .5 ):
return 'Vollmond';
break;
case ( $phase <= ($Period_6 - .5) ):
return 'Dreiviertelmond, abnehmend';
break;
case ( $phase <= (2 * $Period_6 - .5) ):
return 'Halbmond, abnehmend';
break;
case ( $phase <= (3 * $Period_6 - .5) ):
return 'Viertelmond, abnehmend';
break;
case ( $phase <= ($halfPeriod +.5) ):
return 'Neumond ';
break;
case ( $phase <= (4 * $Period_6 - .5) ):
return 'Viertelmond, zunehmend ';
break;
case ( $phase <= (5 * $Period_6 - .5) ):
return 'Halbmond, zunehmend ';
break;
case ( $phase <= (6 * $Period_6 - .5) ):
return 'Dreiviertelmond, zunehmend ';
break;
default:
return 'Vollmond';
}
} else {
return false;
}
}
/**** Test: ****
$m=1; $y=2016;
for ($d=1; $d<=366; $d++) {
echo "$d.$m.$y :\t", FtxMondPhase($d, $m, $y), "\n";
}
#*/