formatoid

1.2.4 • Public • Published

formatoid

Support me on Patreon Buy me a book PayPal Ask me anything Version Downloads Get help on Codementor

Buy Me A Coffee

Tiny and fast module for formatting date objects.

☁️ Installation

# Using npm 
npm install --save formatoid
 
# Using yarn 
yarn add formatoid

📋 Example

const formatoid = require("formatoid");
 
var d = new Date(1989, 11, 21);
 
console.log(formatoid(d, "MM/DD/YYYY, h:mm"));
// => 12/20/1989, 12:00
 
console.log(formatoid(d, "MMMM D, YYYY"));
// => December 20, 1989
 
console.log(formatoid(d, "dddd, MMMM, D, YYYY h:m A"));
// => Wednesday, December, 20, 1989 12:0 AM
 
console.log(formatoid(d, "YYYYMMDDT0HHMMSSZ"));
// => 19891221T0001200+02:00
 
d._useUTC = true;
console.log(formatoid(d, "dddd, MMMM, D, YYYY h:m A"));
// => 19891221T0001200+02:00

❓ Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
  2. For bug reports and feature requests, open issues. 🐛
  3. For direct and quick help, you can use Codementor. 🚀

📝 Documentation

formatoid(i, f)

Formats the date into a given format.

Usable format fields:

  • Years
    • YYYY (e.g. "2015")
    • YY (e.g. "15")
  • Months
    • MMMM (e.g. "January")
    • MMM (e.g. "Jan")
    • MM (e.g. "01")
    • M (e.g. "1")
  • Days
    • dddd (e.g. "Sunday")
    • ddd (e.g. "Sun")
    • dd (e.g. "Su")
    • d (e.g. "Su")
  • Dates
    • DD (e.g. "07")
    • D (e.g. "7")
  • AM/PM
    • A (e.g. "AM")
    • a (e.g. "pm")
  • Hours
    • hh (e.g. "07")–12 hour format
    • h (e.g. "7")
    • HH (e.g. "07")–24 hour format
    • H (e.g. "7")
  • Minutes
    • mm (e.g. "07")
    • m (e.g. "7")
  • Seconds
    • ss (e.g. "07")
    • s (e.g. "7")
  • Fractional seconds
    • S (e.g. 0 1 2 3 ... 9)
    • SS (e.g. 00 01 02 ... 98 99)
    • SS (e.g. 000 001 002 ... 998 999)
  • Timezones
    • Z (e.g. -07:00 -06:00 ... +06:00 +07:00)
    • ZZ (e.g. -0700 -0600 ... +0600 +0700)

Params

  • Date i: The date object.
  • String f: The date format.

Return

  • String The formatted date (as string).

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

💖 Support my projects

I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like 🚀

  • Buy me a book—I love books! I will remember you after years if you buy me one. 😁 📖

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. 🍵

  • Support me on Patreon—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).

  • Bitcoin—You can send me bitcoins at this address (or scanning the code below): 1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6

Thanks! ❤️

💫 Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

  • daty
  • github-calendar
  • react-github-calendar-x
  • @xwl7001/react-github-calendar

📜 License

MIT © Ionică Bizău

Readme

Keywords

Package Sidebar

Install

npm i formatoid

Weekly Downloads

705

Version

1.2.4

License

MIT

Unpacked Size

12.9 kB

Total Files

4

Last publish

Collaborators

  • ionicabizau