Answers.Body: <p>Craft's Date/Time field extends PHP's DateTime class so (since 5.3.0) you can use the <a href="http://php.net/manual/en/datetime.diff.php">Diff</a> method like so:</p>
  
  <pre><code>yourDateTimeField.diff(now).format('%y')
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-10T09:00:47.663Z
Answers.LastActivityDate: 2015-04-10T09:13:03.743Z
Answers.LastEditDate: 2015-04-10T09:13:03.743Z
Answers.UserDisplayName: Adam Gilleard
Body: <p>I have an entry with a dateOfBirth Date/Time Field.</p>
  
  <p>Is it possible to calculate the current age from that field?</p>
  
  <p>I can't find a craft/twig function/filter to calculate the difference between 2 dates.</p>
  
Tags: <datetime>
Title: Get Age from Date of Birth
ThreadText: # Get Age from Date of Birth
  
  (Asked by: username_0 on 2015-04-10)
  
  I have an entry with a dateOfBirth Date/Time Field.
  
  Is it possible to calculate the current age from that field?
  
  I can't find a craft/twig function/filter to calculate the difference between 2 dates.
  
  **Tags:** datetime
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-04-10. Score: 14 | Accepted answer
  
  Craft's Date/Time field extends PHP's DateTime class so (since 5.3.0) you can use the [Diff](http://php.net/manual/en/datetime.diff.php) method like so:
  
  ```
  yourDateTimeField.diff(now).format('%y')
  
  ```
  
  
  ---
  
  