Start and stop a timer PHP

前端 未结 8 778
北海茫月
北海茫月 2020-11-30 08:08

I need some information regarding starting and stopping a timer in PHP. I need to measure the elapsed time from the start of my .exe program (I\'m using exec()

8条回答
  •  既然无缘
    2020-11-30 09:06

    Since PHP 7.3 the hrtime function should be used for any timing.

    $start = hrtime(true);
    // execute...
    $end = hrtime(true);   
    
    echo ($end - $start);                // Nanoseconds
    echo ($end - $start) / 1000000000;   // Seconds
    

    The mentioned microtime function relies on the system clock. Which can be modified e.g. by the ntpd program on ubuntu or just the sysadmin.

提交回复
热议问题