$ npm install formatoid
Tiny and fast module for formatting date objects.
# Using npm
npm install --save formatoid
# Using yarn
yarn add formatoid
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
There are few ways to get help:
formatoid(i, f)
Formats the date into a given format.
Usable format fields:
YYYY
(e.g. "2015"
)YY
(e.g. "15"
)MMMM
(e.g. "January"
)MMM
(e.g. "Jan"
)MM
(e.g. "01"
)M
(e.g. "1"
)dddd
(e.g. "Sunday"
)ddd
(e.g. "Sun"
)dd
(e.g. "Su"
)d
(e.g. "Su"
)DD
(e.g. "07"
)D
(e.g. "7"
)A
(e.g. "AM"
)a
(e.g. "pm"
)hh
(e.g. "07"
)–12 hour formath
(e.g. "7"
)HH
(e.g. "07"
)–24 hour formatH
(e.g. "7"
)mm
(e.g. "07"
)m
(e.g. "7"
)ss
(e.g. "07"
)s
(e.g. "7"
)S
(e.g. 0 1 2 3 ... 9
)SS
(e.g. 00 01 02 ... 98 99
)SS
(e.g. 000 001 002 ... 998 999
)Z
(e.g. -07:00 -06:00 ... +06:00 +07:00
)ZZ
(e.g. -0700 -0600 ... +0600 +0700
)i
: The date object.f
: The date format.Have an idea? Found a bug? See how to contribute.
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:
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
© 2010 - cnpmjs.org x YWFE | Home | YWFE