$.date.months

Months method of date helpers

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.

Last updated

Was this helpful?