Calculate Script Duration in PHP and BASHBASH
#!/bin/bash #start of script time_start=`date +%s` #do stuff sleep 65 #end of script time_end=`date +%s` time_elapsed=$((time_end - time_start)) echo "script executed in $time_elapsed seconds" echo $(( time_elapsed / 60 ))m $(( time_elapsed % 60 ))s Replace "sleep 65" above with the bash command you wish to time. PHP <?php //put this at the start of your php script. $s_mt = explode(" ",microtime()); //do stuff sleep(65); //put this at the end of your php script $e_mt = explode(" ",microtime()); $s = (($e_mt[1] + $e_mt[0]) - ($s_mt[1] + $s_mt[0])); echo "script executed in ".$s." seconds"; echo ($s/60)."m ".($s%60)." s"; ?> In both cases it would output: script executed in 65 seconds
1m 5s | Related Articles php Calculate Script Duration in PHP and... Generate CSV Spreadsheet with PHP Generate PDFs with PHP Generate XLS Spreadsheet files with ... How to properly escape inline javasc... HTML Table Row Highlight PHP - Resize an Image with GD PHP Calculate Duration of MP3 PHP Create Zip file PHP mail Function With Attachments |