小编mar*_*ell的帖子

PHP中日出和日落时间的计算

注意:这是我的好奇心练习,已有解决此问题的功能/代码(另请参见注释)

可以在此处找到用于计算日出和日落时间的算法,以及在1 in Tcl2 in的实现javascript

我正在尝试将算法转换为PHP,但是这有点麻烦,并且花费太多时间。到目前为止,这是我的结果:

<?php
$sunrise = sunriseSunsetTimeTest(9, 4, 2015, 46.929512, 7.565272);
$sunset = sunriseSunsetTimeTest(9, 4, 20, 46.929512, 7.565272, 'sunset');

echo $sunrise . '/' . $sunset;
/* output is: 12.314714533758/12.612340511889 (?) */

function sunriseSunsetTimeTest($day, $month, $year, $latitude, $longitude,
                                    $which='sunrise', $localTimeOffset=1, $zenith=96){
    /*
     * Output:
     * sunrise or sunset time depending on parameter $which
     *
     * Input:
     * (int) day
     * (int) month
     * (int) year
     * (float) latitude_degree
     * (float) longitude_degree …
Run Code Online (Sandbox Code Playgroud)

php trigonometry date-sunrise

5
推荐指数
0
解决办法
1036
查看次数

标签 统计

date-sunrise ×1

php ×1

trigonometry ×1