title: Calculate age with PHP in YYYY MM DD format
body: <p>I'm trying to get this code to calculate the age from a field in a form.</p>
  
  <pre><code>&lt;?php
     $birthDate = "$dob";
  
     $birthDate = explode("-", $birthDate);
  
     $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) &gt; date("md") ? ((date("Y")-$birthDate[2])-1):(date("Y")-$birthDate[2]));
     echo "Age is: ".$age;
  ?&gt;
  </code></pre>
  
  <p>but i can't get it to use the format of the input field which is YYYY-MM-DD.</p>
  
  <p>If i change $dob to a date in the eu standard format that PHP uses it works like a charm.</p>
  
  <p>Is there some easy way to correct this? </p>