0.0.15 • Published 2 years ago

rich-date v0.0.15

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

rich-date

The rich-date is the npm package, that makes your work with dates much easier.

Installation

npm i rich-date

Using

1) Import richDate function to your file:

import { richDate } from 'rich-date';

2) To create current date please call the function without parameters:

const date = richDate();

3) To create a specific date you can pass as parameter one of following data types:

a) Date object

You can just create Date object for concrete date and pass it as parameter Example:

const date = richDate(new Date('2022-09-24'));

b) string

You can pass as parameter some string with date Example:

const date = richDate('2022-09-24');

c) number

You can pass as parameter the number of milliseconds since the 1st of January 1970 Example:

const date = richDate(1663977600000);

4) To receive date string from RichDate object you can just use format method

Example:

const date = richDate('2022-09-24');
date.format(); // 24.09.2022

If you need to customize the output format, you can easily pass as parameter your own output pattern Example:

date.format('DD.MM.YYYY HH:mm:ss') // 24.09.2022 19:25:53
date.format('DD-MM-YYYY'); // 24-09-2022

5) Other methods (e.g. diff, isBefore, isAfter, isBetween, add, subtract) are pretty similar to momentjs package

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago