Posted By

Garciat on 12/24/08


Tagged


Versions (?)

esupergood - format_time() function tweak


 / Published in: PHP
 

  1. /* --> Dont paste this line <-- */
  2. $d = $time - $timestamp;
  3. if ($d < 60)
  4. return $d." second".(($d==1)?'':'s')." ago";
  5. else
  6. {
  7. $d = floor($d / 60);
  8. if($d < 60)
  9. return $d." minute".(($d==1)?'':'s')." ago";
  10. else
  11. {
  12. $d = floor($d / 60);
  13. if($d < 24)
  14. return $d." hour".(($d==1)?'':'s')." ago";
  15. else
  16. {
  17. $d = floor($d / 24);
  18. if($d < 7)
  19. return $d." day".(($d==1)?'':'s')." ago";
  20. else
  21. {
  22. $d = floor($d / 7);
  23. if($d < 4)
  24. return $d." week".(($d==1)?'':'s')." ago";
  25. }//Week
  26. }//Day
  27. }//Hour
  28. }//Minute

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: davidsword on December 25, 2008

what would $d be?

Posted By: davidsword on December 25, 2008

oh seconds..

Posted By: lambneck on May 26, 2009

How to echo this?

You need to login to post a comment.