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
    New Coder
    Join Date
    Apr 2007
    Posts
    34
    Thanks
    1
    Thanked 1 Time in 1 Post

    Working with Runtimes in PHP

    I have a number of runtimes strings such as "00:03:54", "00:01:57", etc. What is the best way to work with these in PHP? Specifically I want to do some comparisons to determine which is greater/smaller. Any help would be appreciated. Thanks in advance.

    --mamamia
    Last edited by mamamia; 10-19-2009 at 11:06 PM.

  • #2
    New Coder
    Join Date
    Apr 2007
    Posts
    34
    Thanks
    1
    Thanked 1 Time in 1 Post
    If anyone cares, I resolved this issue by splitting the runtime string into parts and then converting each part to seconds. Here is the code snippet:

    PHP Code:
    $timeparts explode(':'$runtime);
    $seconds = ($timeparts[0] * 60 60) + ($timeparts[1] * 60) + $timeparts[2]); 
    Also, in PHP 5.3 there is a new class called DateInterval that can probably assist in working with such types, but I'm still on PHP 5.2.x and so I never got a chance to try out that class.

    --mamamia


  •  

    Posting Permissions

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