formatoid
v1.2.4
Published
Tiny and fast module for formatting date objects.
Downloads
5,106
Readme
formatoid
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:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. :bug:
- 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 formath
(e.g."7"
)HH
(e.g."07"
)–24 hour formatH
(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:
—I love books! I will remember you after years if you buy me one. :grin: :book:
—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
—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