Created
December 8, 2020 16:35
-
-
Save cezarpopa/3080e36c19b7f8ac6e445c71d3e2309b to your computer and use it in GitHub Desktop.
microtime to seconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function format_period($seconds_input) | |
{ | |
$hours = (int)($minutes = (int)($seconds = (int)($milliseconds = (int)($seconds_input * 1000)) / 1000) / 60) / 60; | |
return $hours . ':' . ($minutes % 60) . ':' . ($seconds % 60) . (($milliseconds === 0) ? '' : '.' . rtrim( | |
$milliseconds % 1000, | |
'0' | |
)); | |
} | |
$startTime = microtime(true); | |
//whatever happens in between | |
echo '<br/>Total execution time in seconds: ' . format_period((microtime(true) - $startTime)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment