Wrong time for `execution_time()` function [duplicate]

Wrong time for `execution_time()` function [duplicate]



This question already has an answer here:


public function execution_time($begin = null)

if($begin == null)
return microtime(true);

else
$result = date("H:i:s", microtime(true) - $begin);
return $result;




I'm trying to count the execution time.
But the problem is when execution time is lesser then 1 hour, it writes wrong timestamp, for example:


$timeBegin = execution_time();
sleep(8);
$time_end = execution_time($timeBegin); // it shows 06:00:08



It lasts only 8 seconds, why 6 hours are appear? Why this happens and how to solve this?



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




2 Answers
2



You get 6 hours difference because of your timezone.


date_default_timezone_set('UTC');



Line, sets time zone to UTC and eliminates the difference.



You need to set the default timezone in your script:



date_default_timezone_set


date_default_timezone_set



Here is the working example



https://codebrace.com/editor/b16b092fb

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

Node.js puppeteer - Use values from array in a loop to cycle through pages