What does this piece of code exactly mean?

Discussion in 'PHP' started by dmi, Nov 8, 2009.

  1. #1
    Hi,

    
    if ((time() - $x_last_ping) > 60 * 60) { ...
    
    Code (markup):
    What does it mean? What's 60 * 60?
     
    dmi, Nov 8, 2009 IP
  2. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    60 seconds x 60 minutes = 1 hour.

    The code says if the current time (time()) minus the last ping time ($x_last_ping) is greater than one hour, then execute the following....
     
    fairuz.ismail, Nov 8, 2009 IP
    dmi likes this.
  3. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #3
    it is 3600 s
    so its waiting for that much time to again ping

    Regards

    Alex
     
    kmap, Nov 8, 2009 IP
    dmi likes this.
  4. izzatz13

    izzatz13 Active Member

    Messages:
    541
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    60
    #4
    isn't it 60ms times 60ms?

    EDIT: oh yeah there's someone who type faster than me :p
     
    izzatz13, Nov 8, 2009 IP
    dmi likes this.
  5. dmi

    dmi Well-Known Member

    Messages:
    2,705
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    140
    #5
    How do I set it to 15 minutes, instead of 1 hour? 60*15 ?
     
    dmi, Nov 8, 2009 IP
  6. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yup, thats correct. You understand it right
     
    fairuz.ismail, Nov 8, 2009 IP
  7. dmi

    dmi Well-Known Member

    Messages:
    2,705
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    140
    #7
    Thanks everyone. Rep added.

    How about this:

    
    		$Now = time();
                    $Duration = 60*60;
    		
    		foreach ($posts as $post) {
    			if ($x_news_active && $x_permission != 2) {
    				$postDate = strtotime($post->post_date);
    				if ($Now - $postDate < $Duration) {
    					$x_execute_this .= "
    ...
    
    Code (markup):
     
    dmi, Nov 8, 2009 IP
  8. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #8
    it says
    for each element of posts, that we call a post, do the following;
    if the news is active and the permission flag is not equal to 2, do the following;
    if the current time minus post time is < than an hour, do the following;
    ........
     
    fairuz.ismail, Nov 8, 2009 IP