为什么date_create()在生产上的行为与在本地流浪者上的行为不同?

时间:2019-03-28 15:40:23

标签: php vagrant oxid

我具有以下客户管理后端结构,该结构在生产中运行正常,但在本地无源测试mashine上已超时。(我在脚本中的错误消息中用注释标记了该行) )。

我已经将执行时间从30增加到300,但是遇到了同样的错误。所以我假设while循环不断运行吗?!

因为tempdate和datetime不满足约束!= 查看错误日志中的时间戳。 我在生产中记录了相同的错误 似乎在生产中像这样创建日期 (2019-03-28 16:30:14.000000)在测试中,它们的微秒也不同,并且不符合!=的while标准以打破循环

问题:
有人可以解释一下为什么 date_create()不会给我几秒钟的时间,但在测试中确实会导致一段时间无法正常工作吗?

public $_datefrom = null;
public $_dateto = null;
public function __construct () {

        //(...deleted stuff to post this.....)
        $datetime1 = date_create($this->_datefrom);
        $datetime2 = date_create($this->_dateto);

        $tempdate = date_create($this->_datefrom);
        $tempdateto = new DateTime();

        $this->_aIntervalDateArray[$tempdate->format('d.m.Y')] = array();
        ini_set('max_execution_time', 300); //300 seconds = 5 minutes
        while($tempdate != $datetime2) {
        print_r("tempdate "); var_dump($tempdate); print_r(" datetime2 ");var_dump($datetime2);print_r("<br>");// debugging
            $tempdate->modify('+1 day'); // row 119  <<<<<<<<
            if($tempdate <= $tempdateto ) {
                $this->_aIntervalDateArray[$tempdate->format('d.m.Y')] = array();
            }
        }

        $this->_datefrompast = $datetime1->modify('-1 year')->format('Y-m-d');
        $this->_datetopast = $datetime2->modify('-1 year')->format('Y-m-d');


        $datetime1_past = date_create($this->_datefrompast);
        $datetime2_past = date_create($this->_datetopast);

        $tempdatePast = date_create($this->_datefrompast);

        $this->_aIntervalDateArrayPast[$tempdatePast->format('d.m.Y')] = array();

        while($tempdatePast != $datetime2_past) {
            $tempdatePast->modify('+1 day');
            if($tempdatePast <= $datetime2_past ) {
                $this->_aIntervalDateArrayPast[$tempdatePast->format('d.m.Y')] = array();
            }
        }

        $interval = date_diff($datetime1, $datetime2);

        $this->_dateinterval = $this->days_between() + 1;

        $this->_user = $oUser = $this->getUser();

        parent::__construct();
    }

错误消息:

  

[2019年3月28日14:14:48.572803] [未捕获的错误] [类型E_ERROR] [文件   /var/www/oxideshop/source/modules/comp/gg_analytics/application/controllers/admin/admin_gganalytics_view.php]   [第119行] [代码] [消息]最大执行时间为300秒   超过]

错误记录:

tempdate
/var/www/oxideshop/source/modules/comp/gg_analytics/application/controllers/admin/admin_gganalytics_view.php:145:
object(DateTime)[38]
  public 'date' => string '2019-03-28 15:13:20.613671' (length=26)
  public 'timezone_type' => int 3
  public 'timezone' => string 'Europe/Berlin' (length=13)

datetime2

/var/www/oxideshop/source/modules/comp/gg_analytics/application/controllers/admin/admin_gganalytics_view.php:145:
object(DateTime)[37]
  public 'date' => string '2019-03-28 15:13:20.613669' (length=26)
  public 'timezone_type' => int 3
  public 'timezone' => string 'Europe/Berlin' (length=13)


tempdate

/var/www/oxideshop/source/modules/comp/gg_analytics/application/controllers/admin/admin_gganalytics_view.php:145:
object(DateTime)[38]
  public 'date' => string '2019-03-29 15:13:20.613671' (length=26)
  public 'timezone_type' => int 3
  public 'timezone' => string 'Europe/Berlin' (length=13)

datetime2

/var/www/oxideshop/source/modules/comp/gg_analytics/application/controllers/admin/admin_gganalytics_view.php:145:
object(DateTime)[37]
  public 'date' => string '2019-03-28 15:13:20.613669' (length=26)
  public 'timezone_type' => int 3
  public 'timezone' => string 'Europe/Berlin' (length=13)

0 个答案:

没有答案