# $.date.months

You may want to get only month names, so you can use this method, months method only have 2 parameters such as locale, short/long/narrow. Locale is a regional language code (e.g. en-US, in-ID, etc.), short is 3 characters of all month names, long is full month name, and narrow is 1 character month name.

```
// without arguments
$.date.months()
//=> ['January', 'February', 'March', 'April', 'May', 'June', 
// 'July', 'August', 'September', 'October', 'November', 
// 'December']

// with locale/language code
$.date.months('id-ID')
//=> ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 
// 'Juli', 'Agustus', 'September', 'Oktober', 'November',  
// 'Desember']

// shorted all month names
$.date.months('en-US', 'short')
//=> ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 
// 'Sep', 'Oct', 'Nov', 'Dec']
```

Also, maybe you want to get only one month name, so we provide another method which is month (without s) method, in this method only have 4 parameters such as year (actually we don't need year for this), month, locale and month type (long/short/narrow).

```
$.date.month(2021, 6, 'id-ID') //=> 'Juni'
```

If you want to create a month helper manually, you can create it by yourself and you can use all the code below.

```
function months(year = 2021, locale = 'en-US', monthType = 'long') {
  const arrayOfMap = []
  for(let i = 0; i <= 11; i++) {
    const utc = new Date(Date.UTC(year, i, 0))
    const format = new Intl.DateTimeFormat(
      locale,
      {
        month: monthType
      }
    ).format(utc)
    arrayOfMap.push([format, utc.getDate()])
  }
  return arrayOfMap
}

months(2020, 'en-US', 'short')
//=> [["Dec",31],["Jan",31],["Feb",29],["Mar",31],["Apr",30],
// ["May",31],["Jun",30],["Jul",31],["Aug",31],["Sep",30],
// ["Oct",31],["Nov",30]]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tedirghazali.gitbook.io/algajs/date/months.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
