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

date-format-library

v1.1.1

Published

date-format-library simplifies date and time formatting in JavaScript, making it effortless to customize date displays for your web applications and projects.

Downloads

3

Readme

date-format-library

The date-format-library is a JavaScript library that simplifies date and time formatting, making it effortless to customize date displays for your web applications and projects.

Installation

You can install this library using npm:

npm install date-format-library

Basic Usage

Import the library in your JavaScript code:

import DateFormat from 'date-format-library

DateFormat library supports the following date formats:

| Format | | :------------- | | Today | | Tomorrow | | Next 7 days | | Next 30 days | | Yesterday | | Last 7 days | | Last 30 days |

Example using "Today" date format (you can use any of the mentioned formats 👆):

-                 --------------------          output;

DateFormat("Today", "dayOfMonth"); //            24

DateFormat("Today", "month"); //                 10

DateFormat("Today", "year"); //                  2023

DateFormat("Today", "dayOfWeek"); //             Tuesday

DateFormat("Today", "shortDate"); //             Oct 24

DateFormat("Today", "fullDate"); //              2023-10-24

DateFormat("Today", "fullDateTime"); //          Tuesday, October 24, 2023 at 5:30 AM

DateFormat("Today", "localDate"); //             Tue Oct 24 2023 18:02:11 GMT+0530 (India Standard Time)

Advanced Usage

To get all date formats as a single object, use the "dateObject" parameter



DateFormat("Today", "YYY-MM-DD", "dateObject")

output:
{
"id": 1,
"fullDate": "2023-10-24",
"label": "Today",
"shortDate": "Oct 24",
"dayOfMonth": 24,
"year": 2023,
"month": 10,
"dayOfWeek": "Tuesday",
"fullDateTime": "Tuesday, October 24, 2023 at 5:30 AM",
"localDate": "2023-10-24T12:32:11.454Z",
"utc": "2023-10-24T12:32:11.454Z",
"longTime": "18:02:11"
}

Custom Date Formats

You can create custom date formats using hyphens

All format options: | YYY-MM-DD | | "YYY-DD-MM | | DD-MM-YYY | | MM-DD-YYY |

-                 --------------------                 output;

DateFormat("Today", "YYY-MM-DD"); //                  2023-10-24

DateFormat("Tomorrow", "YYY-DD-MM"); //               2023-25-10

DateFormat("Next 7 days", "DD-MM-YYY"); //            31-10-2023

DateFormat("Yesterday", "MM-DD-YYY"); //              10-23-2023

You can create custom date formats using slashes:

All format options: | YYY-MM-DD | | "YYY-DD-MM | | DD-MM-YYY | | MM-DD-YYY |

output;

DateFormat("Today", "YYY/MM/DD"); //                  2023/10/24

DateFormat("Yesterday", "YYY/DD/MM"); //              2023/23/10

DateFormat("Last 7 days", "DD/MM/YYY"); //            17/10/2023

DateFormat("Last 30 days", "MM/DD/YYY"); //           09/24/20233

Advanced Options

You can also retrieve date formats as date objects:


DateFormat("Today", "YYY-MM-DD", "dateObject")

DateFormat("Tomorrow", "YYY-MM-DD", "dateObject")

DateFormat("Next 7 days", "YYY-MM-DD", "dateObject")

DateFormat("Next 30 days", "YYY-MM-DD", "dateObject")

DateFormat("Yesterday", "YYY-MM-DD", "dateObject")

DateFormat("Last 7 days", "YYY-MM-DD", "dateObject")

DateFormat("Last 30 days", "YYY-MM-DD", "dateObject")

// Sample output


{
"id": 1,
"fullDate": "2023-10-24",
"label": "Today",
"shortDate": "Oct 24",
"dayOfMonth": 24,
"year": 2023,
"month": 10,
"dayOfWeek": "Tuesday",
"fullDateTime": "Tuesday, October 24, 2023 at 5:30 AM",
"localDate": "2023-10-24T12:32:11.454Z",
"utc": "2023-10-24T12:32:11.454Z",
"longTime": "18:02:11"
}

New Advanced Options

you can recive array of object for all the possible days

| Format | | :------------- | | Today | | Tomorrow | | Next 7 days | | Next 30 days | | Yesterday | | Last 7 days | | Last 30 days |



DateFormat("AllDays", "YYY-MM-DD")
DateFormat("AllDays", "YYY/MM/DD")

// Sample output

[{
"id": 1,
"fullDate": "2023-10-24",
"label": "Today",
"shortDate": "Oct 24",
"dayOfMonth": 24,
"year": 2023,
"month": 10,
"dayOfWeek": "Tuesday",
"fullDateTime": "Tuesday, October 24, 2023 at 5:30 AM",
"localDate": "2023-10-24T12:32:11.454Z",
"utc": "2023-10-24T12:32:11.454Z",
"longTime": "18:02:11"
},
you will get balance option object list also....
]

Promises

We're currently working on an update for this package. Stay tuned for upcoming improvements and exciting new features! Your ongoing support is greatly appreciated.

License

(c) 2023 Pugal Bharathi, MIT license.