1.0.4 • Published 7 months ago

react-dateformat v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

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 📖🔤🔑

PlaceholderDescriptionExample Value
YYYYFull year2024
YYTwo-digit year24
MMMonth (zero-padded)12
DDDay of the month (zero-padded)17
HHHour (24-hour format)15
hhHour (12-hour format)03
mmMinutes30
ssSeconds45
atAM/PMPM
monthShort month nameDec
fullMonthFull month nameDecember

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 🎉💻✨

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago