Date

Members

static, constant DAY :number Source

Day in milliseconds

static, constant DAYAFTERTOMORROW :number Source

Day after tomorrow in milliseconds

static, constant HOUR :number Source

Hour in milliseconds

static, constant MINUTE :number Source

Minute in milliseconds

static, constant SECOND :number Source

Second in milliseconds

static, constant TODAY :number Source

Today in milliseconds

static, constant TOMORROW :number Source

Tomorrow in milliseconds

static, constant WEEK :number Source

Week in milliseconds

static, constant YESTERDAY :number Source

Yesterday in milliseconds

Methods

addTime(time) → {number}

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

daysPassed(toDateopt) → {number}

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

toCustomDate(format) → {string}

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

toInputDateFormat() → {string}

Returns this Date in forms input date string
Returns:
string - Date string

toInputTimeFormat() → {string}

Returns this Date in form inputs time string
Returns:
string - Time string

toUiDate() → {string}

Returns this Date in UI date string
Returns:
string - Date string
See:
  • Date#getLocalDateFormat

toUiDateTime(showSecondsopt) → {string}

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

toUiTime(showSecondsopt) → {string}

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

static daysFromNow(days) → {number}

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

static getHms(time) → {Object}

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

static getLocalDateFormat(fullFormatopt) → {string}

Get local date format
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:
string - Local date format

static getTimezoneName() → {string}

Get timezone name
Returns:
string - Timezone

static parseValue(value) → {Date}

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!
Parameters:
Name Type Description
value * Value to be parsed
Throws:
Will throw an error if the value is not supported.
Returns:
Date - New Date

static toHmsFormat(time, accuracyopt) → {string}

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

static toStopwatchFormat(time) → {string}

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

static toTimerFormat(time) → {string}

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