compare time for multiple cases

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • huda89
    New Member
    • Oct 2012
    • 31

    compare time for multiple cases

    how can i apply the below code for multiple cases? where the cases have different goal time, is it possible? Thank you =)


    Code:
    <?php
        $currenttime = date("H:i:s");
        $goaltime = "09:12:00";
        
        echo "
        Current time: $currenttime<br>
        Goal time: $goaltime<p>
        ";
      
    
        
        echo "<meta http-equiv= 'refresh' content='1'>";
        
        if ($currenttime >= $goaltime)
        {
        echo "<b>Goal has been reached!</b>";
        echo "<div align=center><img src=\"images/yellow.jpg\" alt=\"bla bla\" ></div>";
        }
        
        else  
        {
        echo "<div align=center><img src=\"images/red.jpg\" alt=\"bla bla\" ></div>";
        echo "Have a nice day!";
        }
        ?>
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    if you have multiple goal times, put them into an array.

    Comment

    • huda89
      New Member
      • Oct 2012
      • 31

      #3
      why the currenttime does not follow my pc time? how can i change it to follow my pc time?

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        I don't know php at all so this is a poke in the dark; however, this seems to deal with using the local pc time:
        http://php.net/manual/en/function.localtime.php There appears tobe some fairly nice examples and some things to consider when implementing the code.

        Comment

        • huda89
          New Member
          • Oct 2012
          • 31

          #5
          dtlite922 + zmbd: Thank you =)

          Comment

          Working...