Constructor
new DateUtils()
- Source:
Methods
(static) SQLtoInt(dateString) → {number}
- Description:
- Converts a string date ("YYYY-MM-DD") to an integer of the form YYYYMMDD.
Bad dates return 0
- Source:
Parameters:
| Name |
Type |
Description |
dateString |
string
|
|
Returns:
-
Type
-
number
(static) calendar(d) → {number}
- Description:
- Convert a julian date into an integer date.
- Source:
Parameters:
| Name |
Type |
Description |
d |
number
|
d the julian date |
Returns:
the integer date formatted as YYYYMMDD
-
Type
-
number
(static) dateAddDays(dt, days) → {Date}
- Description:
- Add days to a Date object
- Source:
Parameters:
| Name |
Type |
Description |
dt |
Date
|
|
days |
number
|
number of days to add or subtract |
Returns:
-
Type
-
Date
(static) dateToInt(dt) → {number}
- Source:
- Deprecated:
- Use DateUtils.toInt()
Convert a Date object to YYYYMMDD int
- See:
-
Parameters:
| Name |
Type |
Description |
dt |
Date
|
|
Returns:
-
Type
-
number
(static) day(dt) → {number}
- Description:
- Return the day portion of a date.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
Date
|
integer date formatted as YYYYMMDD or a Date object |
Returns:
-
Type
-
number
(static) dayOfWeek(dt) → {number}
- Description:
- Takes an integer date formatted as YYYYMMDD and returns an integer
indicating the day of the week.
0 Sunday
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saturday
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
integer date formatted as YYYYMMDD |
Returns:
an integer indicating the day of the week
-
Type
-
number
(static) dayOfWeekName(dt) → {string}
- Description:
- Takes an integer date formatted as YYYYMMDD and returns the
name of the day of the week as a string such as
"Sunday", "Monday", etc.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
integer date formatted as YYYYMMDD |
Returns:
the name of the day of the week
-
Type
-
string
(static) daysDifference(dt1, dt2) → {number}
- Description:
- Return the number of days between two dates.
- Source:
Parameters:
| Name |
Type |
Description |
dt1 |
number
|
date formatted as YYYYMMDD |
dt2 |
number
|
date formatted as YYYYMMDD |
Returns:
returns the number of days dt1 - dt2
-
Type
-
number
- Description:
- Detects the date format based on the given locale.
- Source:
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
locale |
string
|
<optional>
|
navigator.language
|
optional locale used to determine the date format. |
Returns:
The detected date format. Possible values are 'MM/DD/YYYY', 'DD/MM/YYYY', or 'Unknown Format'.
-
Type
-
string
(static) intAddDays(dt, days) → {int}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
int date YYYYMMDD |
days |
number
|
number of days to add or subtract |
Returns:
-
Type
-
int
(static) intToDate(dt) → {Date}
- Description:
- Convert an int date YYYYMMDD to a JavaScrip Date object
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
|
Returns:
-
Type
-
Date
(static) intToSQL(dt) → {string}
- Description:
- Convert a date to string yyyy-mm-dd
- Source:
Parameters:
| Name |
Type |
Description |
dt |
|
YYYYMMDD, YYYYMMDDHHMM, Date, milliseconds, or string |
Returns:
-
Type
-
string
(static) intToStr2(dt, tzopt) → {string}
- Description:
- Convert a date to a locale-appropriate string
using 2-digit year: "mm/dd/yy", "dd/mm/yy", etc.
- Source:
Parameters:
| Name |
Type |
Attributes |
Description |
dt |
number
|
string
|
Date
|
|
– YYYYMMDD, Date, millis, or numeric string |
tz |
string
|
<optional>
|
– IANA zone (e.g. "America/New_York");
omit/falsy ⇒ use the host’s zone |
Returns:
-
Type
-
string
(static) intToStr4(dt, tzopt) → {string}
- Description:
- Convert a numeric date to a locale-appropriate string
(e.g. "05/07/2025" or "07/05/2025" depending on the user’s locale).
- Source:
Parameters:
| Name |
Type |
Attributes |
Description |
dt |
number
|
string
|
Date
|
|
– value in YYYYMMDD form *or* milliseconds |
tz |
string
|
<optional>
|
– IANA zone name; omit/falsy ⇒ host’s zone |
Returns:
-
Type
-
string
(static) isSQLDate(val) → {boolean}
- Description:
- Verify SQL date formatted like YYYY-MM-DD
- Source:
Parameters:
| Name |
Type |
Description |
val |
string
|
|
Returns:
-
Type
-
boolean
(static) isValid(dt) → {boolean}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
dt |
|
number, string, or date |
Returns:
true if valid date
-
Type
-
boolean
(static) julian(dt) → {number}
- Description:
- Convert an integer date into a julian date.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
integer date formatted as YYYYMMDD |
Returns:
the julian date
-
Type
-
number
- Description:
- Formats a date into a string format as in: Mon January 12, 2021
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
integer date formatted as YYYYMMDD |
Returns:
-
Type
-
string
(static) millsToInt(m) → {number}
- Source:
- Deprecated:
- Use DateUtils.toInt()
Convert a number of milliseconds since 1970 UTC to an integer date YYYYMMDD.
This takes into account the local timezone.
- See:
-
- DateUtils.toInt()
- DateTimeUtils.toMilliseconds()
Parameters:
| Name |
Type |
Description |
m |
number
|
number of milliseconds since 1970 UTC |
Returns:
YYYYMMDD
-
Type
-
number
(static) month(dt) → {number}
- Description:
- Return the month portion of a date.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
Date
|
integer date formatted as YYYYMMDD or a Date object |
Returns:
-
Type
-
number
(static) monthName(dt) → {string}
- Description:
- Takes an integer date formatted as YYYYMMDD and returns the
name of the month as a string such as
"January", "February", etc.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
integer date formatted as YYYYMMDD |
Returns:
the name of the day of the week
-
Type
-
string
(static) monthsDifference(idt1, idt2) → {number}
- Description:
- Return the number of months between two dates.
- Source:
Parameters:
| Name |
Type |
Description |
idt1 |
number
|
Date or integer date YYYYMMDD |
idt2 |
number
|
Date or integer date YYYYMMDD |
Returns:
number of months between the two dates
-
Type
-
number
(static) strToInt(dateString) → {number}
- Description:
- Converts a string in any of the following formats to an int YYYYMMDD:
"mM/dD/yyYY" or "dD/mM/yyYY" (depending on locale)
"mmddyyyy" or "ddmmyyyy" (depending on locale)
"yyyymmdd"
"YYYY-MM-DD" or "YYYY/MM/DD"
Bad dates return 0
Takes into account local standard formats.
- Source:
Parameters:
| Name |
Type |
Description |
dateString |
string
|
|
Returns:
-
Type
-
number
(static) toInt(dt) → {number}
- Description:
- Convert a JavaScript Date, a string, an integer date in the form of YYYYMMDD, YYYYMMDDHHMM, or the number of milliseconds
since the epoch and returns a date formated as an integer in YYYYMMDD format.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
|
number, string, or date |
Returns:
YYYYMMDD or zero
-
Type
-
number
(static) today() → {number}
- Description:
- Returns the current date as an int formatted as YYYYMMDD
- Source:
Returns:
-
Type
-
number
(static) year(dt) → {number}
- Description:
- Return the year portion of a date.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
number
|
Date
|
integer date formatted as YYYYMMDD or a Date object |
Returns:
-
Type
-
number