title: PHP MySQLi getting invoice due and working out if its late
body: <p>I have a function i have done that gets the invoice_due_date, it could be in either format: 12/06/2015 or could be  06/12/2015 however i am very new to this and a little lost on how i can do what i want to do.</p>
  
  <p>I need to get date (either format) DD/MM/YYYY or MM/DD/YYYY and compare the date to todays date and if its late to show how many invoices are late.</p>
  
  <p>I guess i need to get the date, check date format and then see if its later than todays today and output the number of how many invoices are late.</p>
  
  <p>PHP so far:</p>
  
  <pre><code>function countLateInvoices() {
      // Connect to the database
      $mysqli = new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME);
  
      // output any connection error
      if ($mysqli-&gt;connect_error) {
          die('Error : ('.$mysqli-&gt;connect_errno .') '. $mysqli-&gt;connect_error);
      }
  
      $query = "SELECT invoice_due_date 
                  FROM `invoices`";
  
      // mysqli select query
      $results = $mysqli-&gt;query($query);
  
      /* determine number of rows result set */
      $row_cnt = $results-&gt;num_rows;
  
      echo $row_cnt;
  
      // Frees the memory associated with a result
      $results-&gt;free();
  
      // close connection 
      $mysqli-&gt;close();
  }
  </code></pre>