Your Ad Here

Posted By

nebojsac on 06/13/11


Tagged

php minutes seconds


Versions (?)

Convert Seconds to Minutes PHP


 / Published in: PHP
 

URL: tricksbycinger.blogspot.com

Takes the seconds, and returns minutes. Will wrap it in a function is anyone is interested. Example: 92s -> 1m 32s

  1. $seconds = 60;
  2. echo "seconds = $seconds<br />";
  3. $start_seconds = round($seconds);
  4. if($start_seconds <60)
  5. {
  6. $minutes ="";
  7. $seconds = $start_seconds;
  8. }
  9. else
  10. {
  11.  
  12. $minutes = floor($start_seconds/60);
  13. $seconds = $start_seconds - $minutes*60;
  14.  
  15. $minutes = "$minutes"."m";
  16. $seconds = $seconds."s";
  17. }
  18. echo "$minutes $seconds";

Report this snippet  

You need to login to post a comment.