SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calculating Minutes/Seconds

    Hey everybody

    Just wondering if anyone knows how to calculate
    how long 0000194 seconds is in minutes and hours.

    I get a 7 int's that are seconds of a phone call. I
    have to change this into a HH:MM:SS format, or
    at least just MM:SS

    I'm sure its simple, I just can't think of the logic

  2. #2
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    These are the calculations for converting seconds to days, hours, minutes and seconds

    PHP Code:
    <?php
    $sek 
    time();
     
    // days
    printf('%d day(s)'$sek 86400);
     
    // hours
    printf('%d hour(s)'$sek 3600 24);
     
    // minutes

    printf('%d minute(s)'$sek 60 60);
     
    // seconds
    printf('%d second(s)'$sek 60);
    ?>

  3. #3
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That isn't what I wanted... (unless I missed something) I want to be able to take 225 seconds and show it as 4 minutes,whatever seconds.

  4. #4
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is what you wanted. Combine the caluculations for minutes and seconds and you get the desired result.

  5. #5
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay, got it working, thank you

    just got a question what's the percent (%) sign do?

  6. #6
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    % is modulo (remainder.)
    PHP Code:
    echo 2//echoes 1
    echo 13 10 //echoes 3 
    TuitionFree — a free library for the self-taught
    Anode Says...Blogging For Your Pleasure


Bookmarks

Posting Permissions

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