Function efficiency of strtotime in php

WBOY
Release: 2016-07-25 09:07:26
Original
1048 people have browsed it
  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.



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!