title: Calculate Age in Gravity FForms
body: <p>I'm trying to calculate the age from the date of birth provided by user in Gravity Form. Now the thing is that I want the age to be stored in a hidden field in the gravity form so that I can use conditional login on that hidden field.</p>
  
  <p>I've added a datepicker for the date of birth, but not sure if my function is ok to calculate the exact age and return it to a parameter which I can use in a hidden field. </p>
  
  <p>Here is the code I've written:</p>
  
  <pre><code>add_filter("gform_field_value_age", "_populate_age");
  function _populate_age( $result, $value, $form, $field ){
      $age = date('Y') - substr($value, 6, 4);
      return $age;
  
  }
  </code></pre>
  
  <p>I know my function is wrong but I was hoping someone can help me out on this.</p>