formatoid
Tiny and fast module for formatting date objects.
Last updated a month ago by ionicabizau .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install formatoid 
SYNC missed versions from official npm registry.

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.

:cloud: Installation

# Using npm
npm install --save formatoid

# Using yarn
yarn add formatoid

:clipboard: 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

:question: 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. :bug:
  3. For direct and quick help, you can use Codementor. :rocket:

:memo: 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).

:yum: How to contribute

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

:sparkling_heart: 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 :rocket:

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

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. :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! :heart:

:dizzy: Where is this library used?

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

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

:scroll: License

MIT © Ionică Bizău

Current Tags

  • 1.2.4                                ...           latest (a month ago)

14 Versions

  • 1.2.4                                ...           a month ago
  • 1.2.3                                ...           2 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.5                                ...           4 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 15
This Month 54
Last Day 15
Last Week 5
Last Month 173
Dependencies (4)
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |