title: PHP compare time variables with if/else
body: <p>I am trying to echo some text depending on the results of a timestamp, using an <code>if/else</code> statement. </p>
  
  <p>My logic is as follows;</p>
  
  <p>Based on the value of <code>$data</code>;</p>
  
  <ul>
  <li>If no results => echo '<em>no results</em>'</li>
  <li>If date is <strong>less than</strong> todays date => echo '<em>expired</em>'</li>
  <li>Else => echo '<em>active</em>'</li>
  </ul>
  
  <p>The problem I am facing is that currently my code always displays 'active' no matter what the date is - my code so far is;</p>
  
  <pre><code>&lt;?php
  
  $data = get_patronapi_data($id);//this contains a date in the format 31-12-13
  
  $dataTimestamp = strtotime($data);//convert date to timestamp
  $now = strtotime('today');set timestamo for $now
  
  //echo strtotime('now'); this outputs 1446820684 
  //echo $dataTimestamp; this outputs 1954886400
  //echo $data; this outputs 31-12-13
  
  //if $data is empty
  if (empty($data)){
      echo 'no results';
  }
  //if $data is not empty but date is less than today
  elseif (!empty($data) &amp;&amp; $dataTimestamp &lt; $now) {
      echo 'expired date is' .$date; //in d-m-y format
  }
  //everything else
  else {
      echo 'active date is ' .$date; //in d-m-y format
  }
  ?&gt;
  </code></pre>
  
  <p>I'm sure the answer will be obvious to a pro but you have a newbie here!</p>