Date & Time helper utilities.
- Description:
Date & Time helper utilities.
Methods
(inner) getAllDayNames(isFullopt, localeopt) → {Array.<string>|undefined}
Get all weekday names.
- Description:
Get all weekday names.
Example
getAllDayNames() // ["Sunday", ...]
getAllDayNames(false) // ["Sun", ...]
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
isFull |
boolean |
<optional> |
true
|
|
locale |
string |
<optional> |
navigator.language
|
Returns:
- Type
- Array.<string> | undefined
(inner) getAllMonths(fullNameopt) → {Array.<string>|undefined}
Get all month names.
- Description:
Get all month names.
Example
getAllMonths() // ["January", ...]
getAllMonths(false) // ["Jan", ...]
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
fullName |
boolean |
<optional> |
true
|
Returns:
- Type
- Array.<string> | undefined
(inner) getDateTime(userDateopt, showTimeopt, is24Houropt, localeopt) → {string}
Get formatted date with optional time.
- Description:
Get formatted date with optional time.
Example
getDateTime() => "10/01/2026, 03:45 PM"
getDateTime('2026-01-10', false) => "10/01/2026"
getDateTime('2026-01-10', true, true) => "10/01/2026, 15:45"
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
userDate |
string | Date |
<optional> |
Date input |
|
showTime |
boolean |
<optional> |
true
|
Include time |
is24Hour |
boolean |
<optional> |
false
|
24-hour format |
locale |
string |
<optional> |
navigator.language
|
Locale |
Returns:
- Type
- string
(inner) getDayName(fullNameopt, userDateopt, localeopt) → {string}
Get weekday name.
- Description:
Get weekday name.
Example
getDayName() // "Monday"
getDayName(false) // "Mon"
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
fullName |
boolean |
<optional> |
true
|
|
userDate |
string | Date |
<optional> |
||
locale |
string |
<optional> |
navigator.language
|
Returns:
- Type
- string
(inner) getFinancialYear(userDateopt, financialYearStartopt) → {string|undefined}
Get financial year for a date.
- Description:
Get financial year for a date.
Example
getFinancialYear('2026-01-10') // "2025-2026"
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
userDate |
string | Date |
<optional> |
||
financialYearStart |
number |
<optional> |
4
|
FY start month (1–12) |
Returns:
- Type
- string | undefined
(inner) getFinancialYearByOffset(offsetopt, financialYearStartopt) → {string|undefined}
Get financial year relative to current FY.
- Description:
Get financial year relative to current FY.
Example
getFinancialYearByOffset(-1) // previous FY
getFinancialYearByOffset(1) // next FY
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
offset |
number |
<optional> |
0
|
-1 previous, +1 next |
financialYearStart |
number |
<optional> |
4
|
Returns:
- Type
- string | undefined
(inner) getFinancialYearsBetween(startDate, endDate, financialYearStartopt) → {Array.<string>|undefined}
Get financial years between two dates.
- Description:
Get financial years between two dates.
Example
getFinancialYearsBetween('2021-01-01', '2024-12-31')
// ["2020-2021", "2021-2022", "2022-2023", "2023-2024"]
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
startDate |
string | Date | Start date |
||
endDate |
string | Date | End date |
||
financialYearStart |
number |
<optional> |
4
|
FY start month (1–12) |
Returns:
- Type
- Array.<string> | undefined
(inner) getMonth(userDateopt) → {number}
Get month number (1–12).
- Description:
Get month number (1–12).
Example
getMonth() // 1
getMonth('2026-05') // 5
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
userDate |
string | Date |
<optional> |
Returns:
- Type
- number
(inner) getMonthName(fullNameopt, userDateopt, localeopt) → {string|undefined}
Get month name.
- Description:
Get month name.
Example
getMonthName(true) // "January"
getMonthName(false) // "Jan"
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
fullName |
boolean |
<optional> |
false
|
Long or short name |
userDate |
string | Date |
<optional> |
||
locale |
string |
<optional> |
navigator.language
|
Returns:
- Type
- string | undefined
(inner) getMonthsBetween(startDate, endDate, optionsopt) → {Array.<(string|number)>|undefined}
Get months between two dates (names or numbers).
- Description:
Get months between two dates (names or numbers).
Example
getMonthsBetween('2026-01-01', '2026-04-01')
// ["January", "February", "March", "April"]
getMonthsBetween('2026-01-01', '2026-04-01', { asNumber: true })
// [1, 2, 3, 4]
getMonthsBetween('2026-01-01', '2026-04-01', { fullName: false })
// ["Jan", "Feb", "Mar", "Apr"]
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
startDate |
string | Date | Start date |
|||||||||||||||||||||
endDate |
string | Date | End date |
|||||||||||||||||||||
options |
Object |
<optional> |
Properties
|
Returns:
- Type
- Array.<(string|number)> | undefined
(inner) getTime(isRailwayopt, dateopt, optionsopt, localeopt) → {string}
Get formatted time string.
- Description:
Get formatted time string.
Example
getTime() // "03:45:10 PM"
getTime(true) // "15:45:10"
getTime(false, '2026-01-10') // Time for given date
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
isRailway |
boolean |
<optional> |
false
|
24-hour format if true |
date |
string | Date |
<optional> |
Custom date |
|
options |
Intl.DateTimeFormatOptions |
<optional> |
Custom time options |
|
locale |
string |
<optional> |
navigator.language
|
Locale |
Returns:
- Type
- string
(inner) getTimeAgo(userDate) → {string}
Get relative time from a given date to now.
- Description:
Get relative time from a given date to now.
Example
getTimeAgo(new Date()) // "few moments ago"
getTimeAgo(Date.now() - 60000) // "1 min ago"
getTimeAgo(Date.now() - 3600000) // "1 hour ago"
Parameters:
| Name | Type | Description |
|---|---|---|
userDate |
string | Date | Past date |
Returns:
- Type
- string
(inner) getYear(userDateopt) → {number}
Get full year.
- Description:
Get full year.
Example
getYear() // 2026
getYear('2020-01') // 2020
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
userDate |
string | Date |
<optional> |
Returns:
- Type
- number
(inner) isWeekend(userDateopt) → {boolean}
Check if date is weekend.
- Description:
Check if date is weekend.
Example
isWeekend('2026-01-11') // true
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
userDate |
string | Date |
<optional> |
Returns:
- Type
- boolean