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

react-dateformat

v1.0.4

Published

A simple date formatting utility for React and Next.js.

Downloads

105

Readme

React DateFormat - A Simple Date Formatting Utility for React & Next.js 🎉✨📅

react-dateformat is a lightweight and easy-to-use utility for formatting dates in React and Next.js applications. It supports both short and full month names and allows custom date formats. 🌟📆🎈

Installation 🚀�️📦

Install the package using npm:

npm install react-dateformat

Or with yarn:

yarn add react-dateformat

Features 🌟🎯📋

  • Supports various placeholders for formatting dates.
  • Provides both short and full month names.
  • Works seamlessly with React and Next.js.
  • Lightweight and easy to use.

Usage 📘🖋️💡

Import the Function 📥📤✨

In your React or Next.js project, import the formatDate function:

import { formatDate } from "react-dateformat";

Examples 🌈📆⚡

Format with Short Month Name 🗓️✂️🧩

const formattedDate = formatDate(new Date("2024-12-17"), "DD-month-YYYY");
console.log(formattedDate); // Output: 17-Dec-2024

Format with Full Month Name 📖📅🌕

const formattedDate = formatDate(new Date("2024-12-17"), "DD-fullMonth-YYYY");
console.log(formattedDate); // Output: 17-December-2024

Format with Time ⏰🕒🔧

const formattedDate = formatDate(
  new Date("2024-12-17T15:30:45Z"),
  "DD-MM-YYYY HH:mm:ss"
);
console.log(formattedDate); // Output: 17-12-2024 15:30:45

Custom Format ✨📅🔧️

You can combine any placeholders to create your own custom formats:

const formattedDate = formatDate(new Date(), "YYYY/MM/DD - HH:mm");
console.log(formattedDate); // Output: 2024/12/17 - 15:45 (based on current date/time)

Format with Two-Digit Year (YY) ✂️⌐⏳

const formattedDate = formatDate(new Date("2024-12-17"), "DD-MM-YY");
console.log(formattedDate); // Output: 17-12-24

Format with 12-Hour Time (hh) 🕑⏳🔄

const formattedDate = formatDate(
  new Date("2024-12-17T15:30:45Z"),
  "DD-MM-YYYY hh:mm"
);
console.log(formattedDate); // Output: 17-12-2024 03:30

Format with AM/PM (at) ⌐☀️🌙

const formattedDate = formatDate(
  new Date("2024-12-17T15:30:45Z"),
  "DD-MM-YYYY hh:mm at"
);
console.log(formattedDate); // Output: 17-12-2024 03:30 PM

Placeholders 📖🔤🔑

| Placeholder | Description | Example Value | | ----------- | ------------------------------ | ------------- | | YYYY | Full year | 2024 | | YY | Two-digit year | 24 | | MM | Month (zero-padded) | 12 | | DD | Day of the month (zero-padded) | 17 | | HH | Hour (24-hour format) | 15 | | hh | Hour (12-hour format) | 03 | | mm | Minutes | 30 | | ss | Seconds | 45 | | at | AM/PM | PM | | month | Short month name | Dec | | fullMonth | Full month name | December |

Contributing 🤝💡🔧

We welcome contributions! If you have suggestions, feature requests, or bug reports, please feel free to create an issue or open a pull request on GitHub. 📝💻🎉

License 📜✔️🌍

This project is licensed under the MIT License. 🎓📜🔓


Star the Repository ⭐🌟✨

If you find this package useful, please consider starring the repository on GitHub to help others discover it! 🌍📢💫


Happy Coding! Remember Your Developer Soumen 🎉💻✨