仅使用UTC时区获取日落时间

问题描述

我一直在为这个问题苦苦挣扎3天,我茫然不知所措。我有以下输入内容

  • 出发和到达的地点(坐标)。
  • 出发时间和到达时间(以UTC为单位)。

我的问题:假设我有一个从某个位置飞往另一个位置的航班,我正在尝试计算日落之后该航班发生的时间。到目前为止,我要做的是在A点和B点之间的设定间隔(相距1分钟)获取坐标。

然后我正在使用PHP的date_sun_info获取该位置的日落时间,但是时间都错了。我怀疑这是问题所在,如何正确处理时区。

到目前为止我尝试过的是:

date_default_timezone_set('UTC');
$deptime= new DateTime($flightdate.' '.$flightdep); //2020-09-22 11:00
...
...  
    // Get coordinates between the two points using PHPGEO and loop:

        foreach ($coords as $value) { // loop through coordinates               
            $sunset = date_sun_info(strtotime($deptime),$value->getLat(),$value->getLng());
            $sunsettime=$sunsetStr['sunset'];
                if ($deptime >date('Y-m-d H:i:s',$sunsettime)) {
                    $nightmin++;
                } else{
                    $totalnightmin='0';
                }
             $deptime ->modify('+1 minutes');  
         }

发布的代码可能不起作用,因为我已经更改了变量名,删除了其他代码,这只是为了让您了解我正在使用的逻辑。这甚至是做我想做的事情的正确方法吗?任何帮助,将不胜感激。我正在尝试使类似的工作: http://www.crewlogbook.com/utilities/night_calculator.php

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)