Home  >  Article  >  Backend Development  >  Function efficiency of strtotime in php

Function efficiency of strtotime in php

WBOY
WBOYOriginal
2016-07-25 09:07:261089browse
  1. $start = array_sum(explode(' ', microtime()));
  2. for($i=0;$i<10000;++$i) {
  3. strtotime("- 1 day");
  4. }
  5. $end = array_sum(explode(' ', microtime()));
  6. echo $end - $start ;
  7. echo '
    ';
  8. $start = array_sum(explode(' ', microtime()));
  9. for($i=0;$i<10000;++$i) {
  10. time() - 86400;
  11. }
  12. $end = array_sum(explode (' ', microtime()));
  13. echo $end - $start ;
  14. ?>
Copy the code

The output result is as follows: 1.13611793518 0.00332498550415

The efficiency difference is 400 times, which is indeed a big difference and deserves attention.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn