1.0.4 • Published 3 years ago

customdateformating v1.0.4

Weekly downloads
7
License
UNLICENSED
Repository
github
Last release
3 years ago

Custom Date Formatting

Build Badge npm Downloads Package Size NPM Version Contributors Commit

How to install?

NPM

Usage

Custom Format date with Days (+/-)

Pass the format of the date required and numberOfDays to add from current day to the Function. For previous days numberOfDays should be passed as negative value.

// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');

// This will return a string with new date
DateFormatting.getNextOrPrevDateCustomFormat("YYYY-MM-DD", 0);

// Output: "2018-10-06"

Custom Format date with Minutes (+/-)

Pass the format of date required and minutesToAdd to add/subtract minutes from current time to the Function. For passed minute of time, minutesToAdd should be passed as negative value.

// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');

// This will return a string with new date and time
DateFormatting.getNextOrPrevMinuteDateCustomFormat("YYYY-MM-DD HH:mm", 1);

// Output: "2018-10-06 00:39"

Custom Format date with Seconds (+/-)

Pass the format of date required and secondsToAdd to add/subtract seconds from current time.For passed minute of time, secondsToAdd should be passed as negative value.

// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');
// This will return a string with new date and time
DateFormatting.getNextOrPrevSecondDateCustomFormat("YYYY-MM-DD HH:mm:ss", 10);

// Output: "2018-10-06 00:40:02"

Custom Source Format date custom new format

Pass the date (input date), currentFormat (input date format), newformat. (required date format)to the Function.

// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');

// This will return a string with date in new format
DateFormatting.customSourceDateFormatToCustomNewDateFormat("2017-08-28 23:22:00", "YYYY-MM-DD HH:mm:ss", "dddd DD MMM YYYY");

// Output: "Monday 28 Aug 2017"

Timestamp from custom date format

Pass the date (input date), currentFormat (input date format)to the function.

// Create Instance of the DateValidator
const DateFormatting = require('customdateformatting');

// This will return input date value as timestamp in milliseconds.
DateFormatting.getTimeStampFromCurrentDateFormat("28 Aug 2017", "DD MMM YYYY");

// Output: 1503858600000

Contributors

Thank you to all the contributors who have helped us in making this project better 🙌

Contributing Guidelines

Read the contributing guidelines here

1.0.4

3 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

6 years ago

0.0.2

7 years ago

0.0.1

7 years ago