getting time from remote downwards counter with PHP?

Discussion in 'PHP' started by dippassa, Jul 15, 2008.

  1. #1
    I'm looking for a best and easiest way to get (parse?) downwards counter numbers (time) from remote server to another. Time in downwards counter can be between 60min - 0min and it can jump (for example) from 2min 30sec back to 60min and it counts again towards zero.

    So I need to get updated counter time from remote server to another. Time have to be update atleast every 30sec or rather constantly.

    What would be best solution to do this?
     
    dippassa, Jul 15, 2008 IP
  2. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Doing it with PHP could be wastage of lots of resources when it can be done with javascript. Use PHP just to get the starting time of the counter.
     
    rohan_shenoy, Jul 15, 2008 IP
  3. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you want to do it on the servere then obviously php is better.
    Post the format of the countdown.
     
    matthewrobertbell, Jul 16, 2008 IP
  4. dippassa

    dippassa Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    format can be either: "33 minutes 42 seconds" (60min - 1min) or "23 seconds" (under 1 minute).
     
    dippassa, Jul 16, 2008 IP
  5. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #5
    $data = "33 minutes 42 seconds";
    if (strpos($data,'minutes')) {
            preg_match('/([0-9]+) minutes ([0-9]+) seconds/',$data,$match);
            $seconds = ($match[1] * 60) + $match[2];
    }
    else {
            preg_match('/([0-9]+) seconds/',$data,$match);
            $seconds = $match[1];
    }
    
    PHP:
     
    matthewrobertbell, Jul 16, 2008 IP