linkorb / php-moon-phase
此包的最新版本(dev-master)没有提供许可证信息。
用于计算月亮相位的PHP类。
dev-master
2013-08-23 07:56 UTC
Requires
- php: >=5.0.0
This package is not auto-updated.
Last update: 2024-09-10 05:08:16 UTC
README
php-moon-phase 是一个用于计算月亮相位及其他相关变量的PHP类。它基于 Moontool for Windows。
使用方法
将 moon-phase.php 文件包含到您的脚本中,然后创建一个 MoonPhase
类的实例,提供一个UNIX时间戳来确定您想要确定的月亮相位(如果您不提供,则使用当前时间)。然后,您可以使用以下类函数来访问对象的属性
phase()
:终止相位角,作为整个圆的分数(即,0到1)。0和1都对应新月,而0.5对应满月。illumination()
:月亮被照亮的分数(0 = 新月,1 = 满月)。age()
:月亮的年龄,以天为单位。distance()
:月亮到地球中心的距离(公里)。diameter()
:从地球中心观察到的月亮的角直径(弧度)。sundistance()
:到太阳的距离(公里)。sundiameter()
:从地球中心观察到的太阳的角直径(弧度)。new_moon()
:上一次新月的时间(UNIX时间戳)。next_new_moon()
:下一次新月的时间(UNIX时间戳)。full_moon()
:当前月周期中的满月时间(UNIX时间戳)。first_quarter()
:当前月周期中的第一次月相的时间(UNIX时间戳)。last_quarter()
:当前月周期中的最后一次月相的时间(UNIX时间戳)。
示例
include 'moon-phase.php';
// create an instance of the class, and use the current time
$moon = new MoonPhase();
$age = round( $moon->age(), 1 );
$stage = $moon->phase() < 0.5 ? 'waxing' : 'waning';
$distance = round( $moon->distance(), 2 );
$next = gmdate( 'G:i:s, j M Y', $moon->next_new_moon() );
echo "The moon is currently $age days old, and is therefore $stage. ";
echo "It is $distance km from the centre of the Earth. ";
echo "The next new moon is at $next.";
帮助
对于错误/增强功能,您可以在GitHub上提出问题或拉取请求,或者 联系我。