@pkopy/dateformat

This module formats date

Usage no npm install needed!

<script type="module">
  import pkopyDateformat from 'https://cdn.skypack.dev/@pkopy/dateformat';
</script>

README

@pkopy/dateformat

xxx

Install

$ npm install @pkopy/dateformat

Usage

const dateToFormat = require("@pkopy/datefomat")

const myDate = new dateToFormat.MyDate()

const x = myDate.dateFormat(new Date('2001-04-01'), 'dmy', '*')

console.log(x)

//=> 01*04*2020

myDate.addDay(10, 'dmy', '-')


Methods

dateFormat([date][, format][,separator])

  • date (optional) is a Date object, if date is null a default is a today date
  • format (optional) is a format a data (string)
    • 'ymd' - year, month, day
    • can use any combination of this three characters
    • if empty a default value is 'mdy'
  • separator (optional) string - if empty a default value is '/'

addDay([number][,format][,separator]) - adds x days to today date

  • number is a positive or negative number
  • format (optional) is a format a data (string)
    • 'ymd' - year, month, day
    • can use any combination of this three characters
    • if empty a default value is 'mdy'
  • separator (optional) string - if empty a default value is '/'