«   2018/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Archives
Today
133
Total
1,103,080
관리 메뉴

Blue Breeze

date, microtime speed and calculate 본문

Language/PHP

date, microtime speed and calculate

푸른바람 푸른_바람 2018.04.25 17:12

Code

<?php $d1 = date('Y-m-d H:i:s').substr(microtime(), 1, 10); $m1 = time().substr(microtime(), 1, 10); $m2 = (double)(time().substr(microtime(), 1, 10)); $m3 = microtime(true); $s1 = date_create()->format("Y-m-d H:i:s.u"); $s2 = date_create()->format("s.u"); $s3 = date_create()->format("c.u"); $s4 = date_create()->format("U.u"); usleep(100); echo "\ndate1 : ". $d1; echo "\nmicrotime1 : ". $m1; echo "\nmicrotime2 : ". $m2; echo "\nmicrotime3 : ". $m3; echo "\ndate_create1 : ". $s1; echo "\ndate_create2 : ". $s2; echo "\ndate_create3 : ". $s3; echo "\ndate_create4 : ". $s4; echo "\n"; echo "\nnow - microtime2 : ". ((double)(time().substr(microtime(), 1, 10)) - $m2) ; echo "\nnow - microtime3 : ". ( microtime(true)- $m3) ; echo "\nnow - date_create2 : ". ( date_create()->format("s.u") - $s2) ; echo "\nnow - date_create4 : ". ( date_create()->format("U.u") - $s4) ; echo "\n";

Result

date1 : 2018-04-25 16:36:44.74041200
microtime1 : 1524643604.74042800
microtime2 : 1524643604.7404
microtime3 : 1524643604.7404
date_create1 : 2018-04-25 16:36:44.740468
date_create2 : 44.740489
date_create3 : 2018-04-25T16:36:44+08:30.740499
date_create4 : 1524643604.740509

now - microtime2 : 0.00031089782714844
now - microtime3 : 0.00030612945556641
now - date_create2 : 0.00028600000000267
now - date_create4 : 0.00029706954956055


'Language > PHP' 카테고리의 다른 글

텍스트 치환 함수 속도 String Replacement Method Speed  (0) 2018.04.26
date, microtime speed and calculate  (0) 2018.04.25
php log file write speed  (0) 2018.04.20
Ubuntu php7.1/7.2 Switch  (0) 2018.03.02
PHP math-php  (0) 2017.06.01
php7.1 Catching Multiple Exception Types  (0) 2017.05.31
0 Comments
댓글쓰기 폼