Date

Namespace

Date

Source:

Members

(static, constant) DAY :number

Description:
  • Day in milliseconds
Source:
Day in milliseconds
Type:
  • number

(static, constant) DAYAFTERTOMORROW :number

Description:
  • Day after tomorrow in milliseconds
Source:
Day after tomorrow in milliseconds
Type:
  • number

(static, constant) HOUR :number

Description:
  • Hour in milliseconds
Source:
Hour in milliseconds
Type:
  • number

(static, constant) MINUTE :number

Description:
  • Minute in milliseconds
Source:
Minute in milliseconds
Type:
  • number

(static, constant) SECOND :number

Description:
  • Second in milliseconds
Source:
Second in milliseconds
Type:
  • number

(static, constant) TODAY :number

Description:
  • Today in milliseconds
Source:
Today in milliseconds
Type:
  • number

(static, constant) TOMORROW :number

Description:
  • Tomorrow in milliseconds
Source:
Tomorrow in milliseconds
Type:
  • number

(static, constant) WEEK :number

Description:
  • Week in milliseconds
Source:
Week in milliseconds
Type:
  • number

(static, constant) YESTERDAY :number

Description:
  • Yesterday in milliseconds
Source:
Yesterday in milliseconds
Type:
  • number

Methods

addTime(time) → {number}

Description:
  • Add time to this Date
Source:
Parameters:
Name Type Description
time number Time to add
Returns:
New timestamp of this Date
Type
number

daysPassed(toDateopt) → {number}

Description:
  • Return number of days passed between this Date and given in argument
Source:
Parameters:
Name Type Attributes Default Description
toDate Date | string | number <optional>
now Proper date
Returns:
Number of days passed
Type
number

toCustomDate(format) → {string}

Description:
  • Returns this Date in custom date format
Source:
Parameters:
Name Type Description
format string String representing date format
Returns:
Date string
Type
string

toInputDateFormat() → {string}

Description:
  • Returns this Date in forms input date string
Source:
Returns:
Date string
Type
string

toInputTimeFormat() → {string}

Description:
  • Returns this Date in form inputs time string
Source:
Returns:
Time string
Type
string

toUiDate() → {string}

Description:
  • Returns this Date in UI date string
Source:
See:
  • Date#getLocalDateFormat
Returns:
Date string
Type
string

toUiDateTime(showSecondsopt) → {string}

Description:
  • Returns this Date in UI datetime string
Source:
Parameters:
Name Type Attributes Default Description
showSeconds boolean <optional>
true Flag if seconds also should be returned
Returns:
Time string
Type
string

toUiTime(showSecondsopt) → {string}

Description:
  • Returns this Date in UI time string
Source:
Parameters:
Name Type Attributes Default Description
showSeconds boolean <optional>
true Flag if seconds also should be returned
Returns:
Time string
Type
string

(static) daysFromNow(days) → {number}

Description:
  • Return timestamp of now + days
Source:
Parameters:
Name Type Description
days number Number of days difference
Returns:
Timestamp
Type
number

(static) getHms(time) → {Object}

Description:
  • Returns object with time parts
Source:
Example
// returns { h: 0, m: 1, s: 1, ms: 500 }
Date.getHms(61500)
Parameters:
Name Type Description
time number Time to be used
Returns:
Time in stopwatch format
Type
Object

(static) getLocalDateFormat(fullFormatopt) → {string}

Description:
  • Get local date format
Source:
Parameters:
Name Type Attributes Default Description
fullFormat boolean <optional>
true Flag if it should be full date format like dd.mm.yyyy instead d.m.y
Returns:
Local date format
Type
string

(static) getTimezoneName() → {string}

Description:
  • Get timezone name
Source:
Returns:
Timezone
Type
string

(static) parseValue(value) → {Date}

Description:
  • Return new Date instance from given value It's simmilar to native Date.parse, but you can use such strings like: 'today', 'yesterday', 'tomorrow', 'dayaftertomorrow', 'now' Feel free to contribute if you think that this method should support even more!
Source:
Parameters:
Name Type Description
value string | number | Date Value to be parsed
Throws:
Will throw an error if the value is not supported.
Returns:
New Date
Type
Date

(static) toHmsFormat(time, accuracyopt) → {string}

Description:
  • Returns given time (in milliseconds) in HMS format
Source:
Example
// returns '1m 5s'
Date.toHmsFormat(61500)
Parameters:
Name Type Attributes Default Description
time number Time to be converted
accuracy string <optional>
seconds Accuracy
Returns:
Time in HMS format
Type
string

(static) toStopwatchFormat(time) → {string}

Description:
  • Returns given time (in milliseconds) in stopwatch format - [HH:]MM:SS.XXX
Source:
Example
// returns '01:01.5'
Date.toStopwatchFormat(61500)
Parameters:
Name Type Description
time number Time to be converted
Returns:
Time in stopwatch format
Type
string

(static) toTimerFormat(time) → {string}

Description:
  • Returns given time (in milliseconds) in timer format - [HH:]MM:SS
Source:
Example
// returns '01:01'
Date.toStopwatchFormat(61500)
Parameters:
Name Type Description
time number Time to be converted
Returns:
Time in timer format
Type
string