<p>I have a "Date of Birth" field, and trying to use the <code>timespan()</code> method to get the age in years. But returns "28 Years, 2 Months, 2 Weeks, 3 Days, 15 Hours, 16 Minutes".</p>

<p>Any idea how I can just get the "28 Years" portion?</p>

There are many ways to do this, with the string in $date, like so:
```
```
$date = '28 Years, 2 Months, 2 Weeks, 3 Days, 15 Hours, 16 Minutes';
```
```
This will give you "28 Years"
```
```
$yearsPart = substr($date, 0, strpos($date, 'Years') + 5);
```
```
So will this:
```
```
$parts = split(', ', $date);
$yearsPart = $parts[0];
```
```