This module is used to generate date and epoch with specific format like 04/07/1995. The aim of this package is to simplify the date-format to readily usable syntax with no further alteration.
Installing
Using npm:
$ npm install @aftabmk/date
Using bower:
$ bower install @aftabmk/date
Using yarn:
$ yarn add @aftabmk/date
Using pnpm:
$ pnpm add @aftabmk/date
Documentation
Functions
getDate
const date : getDate(number,number,number,boolean,string)
getDateNow
const dateNow : getDateNow(number,number,number,boolean,string)
getEpoch
const epoch : getEpoch(string,string)
getEpochNow
const epoch : getEpoch(null)
getDate inputs
Day(week ago)
const dateNow = getDate(7,0,0,true,'forwardSlash')
// current 10/05/2022
// result 03/05/2022
// logic day = 10-7 = 2
Month(Quarter ago)
const dateNow = getDate(0,3,0,true,'forwardSlash')
// current 02/12/22
// result 02/9/22
// logic day = 12-3 = 9
Year(decade ago)
const dateNow = getDate(0,0,10,true,'forwardSlash')
// current 02/12/22
// result 02/9/12
// logic day = 22-10 = 12
True
const dateNow = getDate(0,0,0,true,'forwardSlash')
// result 01/01/22
False
const dateNow = getDate(0,0,0,false,'forwardSlash')
// result 01/01/2022
Examples of input symbols
Ampersand(&)
const dateNow = getDate(0,0,0,false,'ampersand')
// result 01&01&2022
Apostrophe(')
const dateNow = getDate(0,0,0,false,'apostrophe')
// result 01'01'2022
Asterisk()*
const dateNow = getDate(0,0,0,false,'asterisk')
// result 01*01*2022
AtSign(@)
const dateNow = getDate(0,0,0,false,'atSign')
// result 01@01@2022
Dot(.)
const dateNow = getDate(0,0,0,false,'dot')
// result 01.01.2022
Dollar($)
const dateNow = getDate(0,0,0,false,'dollar')
// result 01$01$2022
Hyphen(-)
const dateNow = getDate(0,0,0,false,'hyphen')
// result 01-01-2022
UnderScore(_)
const dateNow = getDate(0,0,0,false,'underScore')
// result 01_01_2022
Exclamation(!)
const dateNow = getDate(0,0,0,false,'exclamation')
// result 01!01!2022
Hash(#)
const dateNow = getDate(0,0,0,false,'hash')
// result 01#01#2022
Quotation(")
const dateNow = getDate(0,0,0,false,'quotation')
// result 01"01"2022
ForwardSlash(/)
const dateNow = getDate(0,0,0,false,'forwardSlash')
// result 01/01/2022
Starter Code
getDate function
const { getDate } = require('@aftabmk/date');
const date = getDate(0,0,0,false,'forwardSlash')
// date now in the format dd/mm/yyyy
// result 01/01/2022
getDateNow function
const { getDateNow } = require('@aftabmk/date');
const date = getDateNow(false,'forwardSlash')
// date now in the format dd/mm/yyyy
// result 01/01/2022(Today date)
getEpoch function
const { getEpoch } = require('@aftabmk/date');
const date = getEpoch('14/07/2002','12:30')
// date format dd/mm/yyyy
// time format hh:mm
// result 1026630000
getEpochNow function
const { getEpochNow } = require('@aftabmk/date');
const date = getEpochNow()
// no input
// result 1613889000000 in sec