Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Unnamed
Friday, June 19th, 2009 at 7:50:32am MDT 

  1. function elapsed_time ( $start, $end = false)
  2. {
  3. if ($end == false) //if you don't pass a second parameter,
  4. $end = time(); //we assume you're comparing to now.
  5.  
  6. $diff = $end - $start;
  7. $days = floor ( $diff/86400 ); //calculate the days
  8. $diff = $diff - ($days*86400); // subtract the days
  9.  
  10. $hours = floor ( $diff/3600 ); // calculate the hours
  11. $diff = $diff - ($hours*3600); // subtract the hours
  12.  
  13. $mins = floor ( $diff/60 ); // calculate the minutes
  14. $diff = $diff - ($mins*60); // subtract the mins
  15.  
  16. $secs = $diff; // what's left is the seconds;
  17. if ($secs > 0) {
  18. $returnval = "$secs second".(($secs>1) ? "s":"")." ago";
  19. }
  20.  
  21. if ($mins > 0) {
  22. $returnval = "$mins minute".(($mins>1) ? "s":"")." ago";
  23. }
  24.  
  25. if ($hours > 0) {
  26. $returnval = "$hours hour".(($hours>1) ? "s":"")." ago";
  27. }
  28.  
  29. if ($days > 0) {
  30. $returnval = "$days day".(($days>1) ? "s":"")." ago";
  31. }
  32.  
  33. $return = "About "; //change the wording to what you like
  34. return $return . $returnval;
  35. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.