Checks if a given var is a Date obj
Arg | Type | Default | Description |
---|---|---|---|
target | any | Var to check |
import {isDate} from "lkt-date-tools";
isDate(new Date()); // Returns true
isDate('date'); // Returns false
Converts a ISO formatted date to a Date object
Arg | Type | Default | Description |
---|---|---|---|
str | string | String to convert |
import {isoToDate} from "lkt-date-tools";
const date = isoToDate('2020-04-23T00:00:00');
Converts a 'Y-m-d' formatted date to a Date object
Arg | Type | Default | Description |
---|---|---|---|
str | string | String to convert |
import {ymdToDate} from "lkt-date-tools";
const date = ymdToDate('2020-04-23');
Returns current time (in seconds)
import {time} from "lkt-date-tools";
const stamp = time();
Returns current time (in milliseconds)
import {timeInMilliseconds} from "lkt-date-tools";
const stamp = timeInMilliseconds();
Returns current timestamp in milliseconds
import {getStampInMilliseconds} from "lkt-date-tools";
const stamp = getStampInMilliseconds();
Returns the seconds in one year
import {getOneYearInSeconds} from "lkt-date-tools";
const stamp = getOneYearInSeconds();
Converts from seconds to milliseconds
Arg | Type | Default | Description |
---|---|---|---|
seconds | number | Seconds to convert |
import {secondsToMilliseconds} from "lkt-date-tools";
const stamp = secondsToMilliseconds();
Converts a Date object to an unix timestamp
Arg | Type | Default | Description |
---|---|---|---|
date | Date | Date to convert |
import {dateToTimestamp} from "lkt-date-tools";
const stamp = dateToTimestamp(new Date());