Methods
(static) addHours(dt, hours) → {Date}
- Source:
Add hours to a date.
Parameters:
Name | Type | Description |
---|---|---|
dt |
Date | number | string | |
hours |
number |
Returns:
- Type
- Date
(static) addMinutes(dt, minutes) → {Date}
- Source:
Add minutes to a date.
Parameters:
Name | Type | Description |
---|---|---|
dt |
Date | number | string | |
minutes |
number |
Returns:
- Type
- Date
(static) createDate(dt, tm) → {Date}
- Source:
Convert in integer date and integer time into a Date object.
Parameters:
Name | Type | Description |
---|---|---|
dt |
YYYYMMDD | |
tm |
HHMM |
Returns:
- Type
- Date
(static) dateToStd(dt, tzopt) → {string}
- Source:
Convert a Date into the canonical interchange string
yyyy-MM-dd HH:mm:ss
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
dt |
Date | number | string | – Date object, millis, or numeric string | |
tz |
string |
<optional> |
– IANA zone name (e.g. "America/New_York"); omit/falsy ⇒ use the host’s local zone |
Returns:
- Type
- string
(static) formatDate(dt, tzopt) → {string}
- Source:
Format a Date or milliseconds-since-epoch value to a string
"mm/dd/yyyy hh:mm AM/PM" or "dd/mm/yyyy hh:mm AM/PM"
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
dt |
Date | string | number | – Date object, millis, or numeric string | |
tz |
string |
<optional> |
– IANA zone (e.g. "America/New_York"); omit or pass falsy to use the local zone |
Returns:
- Type
- string
(static) formatDateLong(dt, tzopt) → {string}
- Source:
Format a moment as "Wed Jan 4, 2022 12:31 PM CST".
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
dt |
Date | number | string | – Date object, epoch-millis, or numeric string | |
tz |
string |
<optional> |
– IANA zone name (e.g. "America/Chicago"); omit/falsy → host’s local zone |
Returns:
- Type
- string
(static) formatDateTime(dt, time, tzopt) → {string}
- Source:
Format a date (YYYYMMDD) and a time (HHMM) as
"mm/dd/yyyy hh:mm AM/PM" or "dd/mm/yyyy hh:mm AM/PM"
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
dt |
number | string | – calendar date, e.g. 20250508 | |
time |
number | string | – clock time, e.g. 1145 | |
tz |
string |
<optional> |
– IANA zone name; omit/falsy ⇒ host’s zone |
Returns:
- Type
- string
(static) getLocalTimezoneLongText() → {string}
- Source:
Returns the local long timezone text.
For example "American/Chicago"
Returns:
- Type
- string
(static) getLocalTimezoneShortText() → {string}
- Source:
Returns the local short timezone text.
For example "CST"
Returns:
- Type
- string
(static) stdToDate(sdt) → {Date}
- Source:
Parse a standard string date format into a Date object.
Expected standard date format looks like this: 2022-06-08 03:27:44 300
The 300 is minutes offset from GMT - the timezone
This routine parses a date from any timezone and returns a Date object in the local timezone.
Parameters:
Name | Type | Description |
---|---|---|
sdt |
string |
Returns:
- Type
- Date
(static) toIntDate(dt, zoneIdopt) → {number}
- Source:
Extract the calendar date as an integer (YYYYMMDD).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
dt |
Date | number | – Date object *or* milliseconds since epoch. | |
zoneId |
string |
<optional> |
– optional IANA time-zone, e.g. "America/New_York". Omit/falsy ⇒ use the host’s local zone. |
Returns:
– YYYYMMDD, or NaN on invalid input.
- Type
- number
(static) toIntTime(dt, zoneIdopt) → {number}
- Source:
Convert a moment in time to an integer clock value (HHMM).
The date portion is ignored.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
dt |
Date | number | – Date instance **or** milliseconds-since-epoch | |
zoneId |
string |
<optional> |
– optional IANA time-zone (e.g. "America/New_York"); omit or falsy → use the host’s local zone |
Returns:
– integer HHMM, or NaN on bad input
- Type
- number
(static) toMilliseconds(date, time) → {number}
- Source:
- See:
-
- DateUtils.millsToInt()
- TimeUtils.millsToInt()
Combine a date and time into the number of milliseconds since 1970 UTC.
This is very valuable when trying to transit a DateTime to a backend without losing timezone info.
Parameters:
Name | Type | Description |
---|---|---|
date |
number | Date | YYYYMMDD (time portion of a Date is not used) |
time |
number | null | undefined | HHMM |
Returns:
- Type
- number