×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
1
Language: PHP
Posted by: Amzad Hossain
Added: Jun 19, 2014 11:51 AM
Modified: Jun 19, 2014 11:52 AM
Views: 1817
Tags: php
  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. $start = time();
  18. $end = time();
  19. print "time_elapsed_A: ".time_elapsed( $end - $start)."\n";
  20.