WordPress.org

Ready to get started?Download WordPress

Forums

PHP to determine if time has past on the server (3 posts)

  1. moonoo
    Member
    Posted 3 years ago #

    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?

  2. moonoo
    Member
    Posted 3 years ago #

    $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.

  3. moonoo
    Member
    Posted 3 years ago #

    This looks right I think:

    $release_date = strtotime($result["released"]);
    $today = strtotime("now");
    			}
    if($release_date <= $today){
    $preorder = ('ORDER');
    }
    else{
    $preorder = ('PREORDER');
    }

Topic Closed

This topic has been closed to new replies.

About this Topic