# getMonthsInDuration()

Returns the number of months in a duration.

## Signature

`getMonthsInDuration(Duration duration)`

## Parameters

***duration*:** Type: `Duration`. The duration object returned by `$A.localizationService.duration`.

## Returns

**Type: `number`** The number of months in the duration.

## Sample Code

```javascript
var dur = $A.localizationService.duration(70, 'day');
// Returns 2, the number of months in the given duration
$A.localizationService.getMonthsInDuration(dur);
```

**See Also**

- [duration()](/docs/platform/aura-platform/guide/ref-jsapi-auralocalizationservice-duration.md)
