«   2018/08   »
      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
156
Total
1,140,336
안정적인 DNS서비스 DNSEver
관리 메뉴

Blue Breeze

date, microtime speed and calculate 본문

Language/PHP

date, microtime speed and calculate

푸른바람 C/H 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


0 Comments
댓글쓰기 폼