Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    how to convert seconds into minutes and seconds?

    if I have a var called $totalSeconds, how do I divide it up into $minutes and $seconds.

    my solution doesn't seem to work:

    $minutes = round($totalSeconds/60);
    $seconds = round($totalSeconds%60);

    how to do this?

  • #2
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    PHP Code:
    $totalSeconds 400;

    $minutes floor($totalSeconds 60); // 6 minutes
    $seconds $totalSeconds - ($minutes 60); // 40 seconds 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •