npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

customdateformating

1.0.2 • Public • Published

Custom Date Formatting

npm version Dependencies npm Downloads Codacy Badge

How to install?

NPM

Small package which provides some basic functions for custom date formatting

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


Contributing Guidelines

Read the contributing guidelines here

install

npm i customdateformating

Downloadsweekly downloads

2

version

1.0.2

license

UNLICENSED

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability