nodedash v1.0.0
Import using esm
or TypeScript
1.0.0
import _n from 'nodedash'
_n.date('3/14/2019', 'uk')
// => 14 Mar 2019
_n.addDays('3/6/19', 1, '-')
// => 03-07-2019
_n.subtractDays('3/6/19', 1, '-')
// => 03-05-2019
nodedash.js
Import individual ES Modules using esm
or TypeScript
1.0.0
import { addDate, subtractDate } from 'nodedash'
addDays('3/6/19', 1, '-')
// => 03-07-2019
subtractDays('3/6/19', 1, '-')
// => 03-05-2019
nodedash.js
Import using require
1.0.0
const _n = require('nodedash')
_n.date('3/14/2019', 'uk')
// => 14 Mar 2019
_n.addDays('3/6/19', 1, '-')
// => 03-07-2019
_n.subtractDays('3/6/19', 1, '-')
// => 03-05-2019
nodedash.js
Computes input date
converts to string and returns with specified format
.
1.0.0
Date
(date): options arenew Date()
,timestamp
orstring
in valid date format. See example below.format
(string):
(string): Returns the date as a String in specified format.
let any_nate = "1/07/2019"
_n.date(any_nate, '/')
// => 01/07/2019
_n.date(any_nate, '-')
// => 01-07-2019
_n.date(any_nate, '.')
// => 01.07.2019
_n.date(any_nate, 'MMM DD YYYY')
// => Jan 07 2019
_n.date(any_nate, 'england')
// => 07 Jan 2019
_n.date(any_nate, 'uk')
// => 07 Jan 2019
_n.date(any_nate, 'full')
// => Mon Jan 07 2019 00:00:00 GMT-0700 (Mountain Standard Time)
nodedash.js
Gets the timestamp of the number of milliseconds that have elapsed since
the Unix epoch (1 January 1970 00
:00:00 UTC).
1.0.0
(number): Returns the timestamp.
const { defer } = require('lodash')
defer(function(stamp) {
console.log(_n.now() - stamp)
}, _n.now())
// => Logs milliseconds it took for the deferred invocation.
nodedash.js
Gets the timestamp of the number of milliseconds that have elapsed since
date
argument. If date
is undefined
it gives milliseconds elapsed since
the Unix epoch (1 January 1970 00
:00:00 UTC).
1.0.0
Date
(date): to convert to timestamp.
(number): Returns the timestamp.
_n.getTimestamp('July 4 1776')
// => 121244400000
_n.getTimestamp()
// => 1552353178563
// returns now timestamp
_n.getTimestamp('11/4/1973')
// => -6106035604000
nodedash.js
Verifies if value
is a valid Date object
and valid Date
.
1.0.0
value
(*): The value to check.
(boolean): Returns true
if value
is a Date object
& valid Date
, else false
.
_n.isDate('3/3/19')
// => true
_n.isDate(new Date())
// => true
_n.isDate('Jul 4 1776')
// => true
_n.isDate(25200000)
// => true
_n.isDate('3/33/19')
// => false
function getDate() {
return '1/1/19'
}
_n.isDate(getDate)
// => false
_n.isDate(getDate())
// => true
nodedash.js
Input _nate
add nDays
with format
1.0.0
Date
(date):days
(number): to addformat
(string):
const any_nate = '3/6/19'
_n.addDays(any_nate, 1, '-')
// => 03-07-2019
_n.addDays(any_nate, 2, '.')
// => 03.08.2019
_n.addDays(any_nate, 3, 'uk')
// => 09 Mar 2019
nodedash.js
Input _nate
subtract nDays
with format
1.0.0
Date
(Date):days
(number): to subtractformat
(string):
const any_nate = '3/6/19'
_n.subtractDays(any_nate, 1, '-')
// => 03-05-2019
_n.subtractDays(any_nate, 2, '.')
// => 03.04.2019
_n.subtractDays(any_nate, 3, 'uk')
// => 03 Mar 2019