npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

multi-date

v1.0.1

Published

Its is the ultimate date formatter!

Downloads

369

Readme

Multi-Date a all in one Dates Library for Javascript.

Multi-date have various functions to make your date handling easy. Please star the repo https://github.com/bdbose/multi-date

Install


npm install --save multi-date

Import

import { formate, customDates } from 'multi-date';
// or
const { format } = require('multi-date');

Doc

format Format date to any string format eg. 'DD-MM-YYYY','DD/MM/YYYY'

const { format } = require('multi-date');

const d1 = format(new Date(), 'DD-MM-YYYY');
const d2 = format(new Date(), 'MM-DD-YYYY');
const d3 = format(new Date(), 'YYYY/MM/DD');
const d4 = format(new Date(), 'DD-MM');

console.log(d1); //  19-03-2022
console.log(d2); //  03-19-2022
console.log(d3); //  2022/03/19
console.log(d4); //  19-03

customDates Add or Substract number of days, month or year

const { customDates } = require('multi-date');

const date1 = customDates(new Date(), 5, 'month');
const date2 = customDates('2022-10-31', 5, 'year');
const date3 = customDates('2016-04-15', -12, 'day');

const res1 = format(date1, 'DD-MM-YYYY');
const res2 = format(date2, 'DD-MM-YYYY');
const res3 = format(date3, 'DD-MM-YYYY');

console.log(res1); //  19-08-2022
console.log(res2); //  31-10-2027
console.log(res3); //  03-04-2016

inBetweenDates Calculate number of days,hours or minutes betweeen two dates

const { inBetweenDates } = require('multi-date');

const diff = inBetweenDates('2022-10-10', '2022-10-15');
const diff1 = inBetweenDates('2022-10-10', '2022-10-15', 'minutes');
const diff2 = inBetweenDates('2022-10-10', '2022-10-15', 'hours');

console.log(diff, 'Days'); //  5 Days
console.log(diff1, 'Minutes'); //  7200 Minutes
console.log(diff2, 'Hours'); //  120 Hours

compareDates Comparing two dates

const { compareDates } = require('multi-date');

const c = compareDates('2022-10-10', new Date());
const c1 = compareDates(new Date(), new Date());
const c2 = compareDates('2020-10-10', '2022-10-10');

console.log(c); // -1 date2 is less than date1
console.log(c1); // 0 both dates are equal
console.log(c2); // 1 date2 is greater than date1