Support » Plugins » Hacks » PHP to determine if time has past on the server

  • I’m trying to figure out how to make this statement work so that the products I show on the front of the site have a Link titled Pre-Order if the Release date has not past and Order if the release date is today or has past.. this is what I have so far, but it doesn’t spit out what I thought it would…

    if(!empty($result["released"])) {
    				$result["released"] = date('d/m/Y', strtotime($result["released"]));
    			}
    if($result["released"] >= date('d/m/Y')){
    $preorder = ('ORDER');
    }
    else{
    $preorder = ('PREORDER');
    }

    Any ideas here?

Viewing 2 replies - 1 through 2 (of 2 total)
  • $exp_date = "2006-01-16";
    $todays_date = date("Y-m-d");
    
    $today = strtotime($todays_date);
    $expiration_date = strtotime($exp_date);
    
    if ($expiration_date > $today) {
         $valid = "yes";
    } else {
         $valid = "no";
    }

    Should look at this I think and see how I can use it in my code.

    This looks right I think:

    $release_date = strtotime($result["released"]);
    $today = strtotime("now");
    			}
    if($release_date <= $today){
    $preorder = ('ORDER');
    }
    else{
    $preorder = ('PREORDER');
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP to determine if time has past on the server’ is closed to new replies.