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

    Converting TotalSeconds to Hours then Minutes then Seconds

    I have a var called $totalBuildSeconds which has a large integer in it representing a time in seconds.

    I need to take that time in seconds and convert it into hours:minutes:seconds, each stored in their own vars $buildHours, $buildMinutes, $buildSeconds

    I am able to get the hours and minutes.. but not the seconds...
    I think my brain is starting to melt.

    Code:
    $buildHours = floor($totalBuildSeconds / 3600);
    $buildMinutes = (($totalBuildSeconds % 3600)*60);
    $buildSeconds = $totalBuildSeconds - ($buildMinutes * 60);

  • #2
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post
    I got it... I think this is the solution:

    Code:
    $buildHours = floor($totalBuildTimeInSeconds / 3600);
    $buildMinutes = floor(($totalBuildTimeInSeconds - ($buildHours*3600))/60);
    $buildSeconds = ($totalBuildTimeInSeconds - ($buildHours*3600)  - ($buildMinutes*60));


  •  

    Posting Permissions

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