- Source:
the JS native Date class
Methods
isDate(d) → {boolean}
- Source:
checks if something is a date
Example
eg.usage
console.log(Date.isDate(new Date())); // true
console.log(Date.isDate(0)); // false
Parameters:
Name | Type | Description |
---|---|---|
d |
* | the value to check |
Returns:
- Type
- boolean
random(startDate, endDate) → {date}
- Source:
returns a random date between specified range (default now <-> now)
Example
eg. usage
console.log(Date.random()); // Mon Jan 22 2018 14:07:09 GMT+0100 (CET)
console.log(Date.random(new Date(1970, 0, 1), new Date())); // Sun Apr 05 1987 00:00:00 GMT+0200 (CEST)
Parameters:
Name | Type | Description |
---|---|---|
startDate |
date | the range start date |
endDate |
date | the range end date |
Returns:
- Type
- date
toTimestamp(d) → {timestamp|0}
- Source:
transforms a date in a UTC timestamp integer
Example
eg. usage
console.log((new Date()).toTimestamp()); // 1491317811925 @ 2017-04-4-16:57
Parameters:
Name | Type | Description |
---|---|---|
d |
date | the date to convert |
Returns:
- Type
- timestamp | 0