Giter Club home page Giter Club logo

custom-date-formatting's Introduction

Custom Date Formatting

npm version Dependencies npm Downloads

How to install?

NPM

Small package which provides some basic functions for custom date formatting

getNextOrPrevDateCustomFormat

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);

getNextOrPrevMinuteDateCustomFormat

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);

getNextOrPrevSecondDateCustomFormat

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);

customSourceDateFormatToCustomNewDateFormat

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");

getTimeStampFromCurrentDateFormat

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

// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');
//This will return input date value as timestamp in milliseconds.
DateFormatting.getTimeStampFromCurrentDateFormat("28 Aug 2017", "DD MMM YYYY");

Contributors


Contributing Guidelines

Read the contributing guidelines here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.