Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. function time_elapsed($secs){
  2.     $bit = array(
  3.         'y' => $secs / 31556926 % 12,
  4.         'w' => $secs / 604800 % 52,
  5.         'd' => $secs / 86400 % 7,
  6.         'h' => $secs / 3600 % 24,
  7.         'm' => $secs / 60 % 60,
  8.         's' => $secs % 60
  9.         );
  10.  
  11.     foreach($bit as $k => $v)
  12.         if($v > 0)$ret[] = $v . $k;
  13.  
  14.     return join(' ', $ret);
  15. }
  16.  
  17. //Tempo inicial
  18. $ini = time();
  19.  
  20. //Tarefa exemplo
  21. sleep(5);  
  22.  
  23. //Tempo final
  24. $out = time();
  25.  
  26. echo time_elapsed($out-$ini);