---
schema_version: "1"
id: de995782aa7c81cb9b9be0d3ece31bef91e8a6d9f6e7ce8983d4ff25d241aa28
title: getMonthsInDuration()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/ref-jsapi/ref-jsapi-auralocalizationservice-getmonthsinduration.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/ref-jsapi-auralocalizationservice-getmonthsinduration.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 46ebfba16cf2fa10d9ea2fcd4faa0884807eb842a45efb162ce0ed9f87662119
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# 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()](https://developer.salesforce.com/docs/platform/aura-platform/guide/ref-jsapi-auralocalizationservice-duration.md)

