@domoskanonos/date-util
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

date-util

useful methods for Date class, f.e. convert date object in string and vice versa.

project info
npm Licence npm version minified size minzipped size downloads/week
github Published on git build
donation donate

convert date object to string

const dateUtil: DateUtil = new DateUtil();
const dateExample = new Date("December 17, 1995 03:24:37");
const dateExampleAsString = dateUtil.formatDate(compareDate, "yyyy-MM-dd");
console.log(dateExampleAsString); // output -> 1995-12-17;

convert string to date object

const dateUtil: DateUtil = new DateUtil();
const dateExample : Date = dateUtil.parseDate("1995-12-17 03:24 37", "yyyy-MM-dd hh:mm ss");

diff dates

const dateUtil: DateUtil = new DateUtil();
dateUtil.diffDays(new Date(2013, 11, 31), new Date(2013, 12, 1)); // output -> 1

replace table for string input

  • d - day
  • y,Y - year
  • M - month
  • h,H - hours
  • m - Minute
  • s - Second
  • S - Milisecond

Readme

Keywords

none

Package Sidebar

Install

npm i @domoskanonos/date-util

Weekly Downloads

3

Version

1.0.4

License

MIT

Unpacked Size

16.4 kB

Total Files

12

Last publish

Collaborators

  • domoskanonos