<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>

CC BY-SA 3.0
2015-04-10T09:00:47.663Z
2015-04-10T09:13:03.743Z
2015-04-10T09:13:03.743Z
Adam Gilleard
<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>

<datetime>
Get Age from Date of Birth
# 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 method like so:
yourDateTimeField.diff(now).format('%y')


---

