Author: | mateusortiz |
---|---|
Views Total: | 355 views |
Official Page: | Go to website |
Last Update: | September 17, 2015 |
License: | MIT |
Preview:

Description:
lengthy is a small and easy-to-use JavaScript library for displaying current date or a specific date with custom formats.
How to use it:
Add lengtht.js JavaScript library to your web page.
<script src="src/lengthy.js"></script>
Create an empty element to display the formatted date.
<span id="date"></span>
Format current local date.
var date = lengthy('dd.MM.YY', new Date()); document.querySelector('#date').innerHTML = date;
Format a specific date.
var date = new Date(); date.setFullYear(2020); lengthy('MM.dd.YYYY', date); // 08.26.2020 document.querySelector('#date').innerHTML = date;
Full date format properties.
- YYYY: 4 digits year.
- YY: Last 2 digits of year.
- MMMM: Full name of month.
- MMM: Short name of month.
- MM: ISO8601-compatible number of month (i.e. zero-padded) in year (with January being 1st month).
- M: Number of month in year without zero-padding (with January being 1st month).
- DD: Full name of day.
- D: Short name of day.
- dd: Zero-padded number of day in month.
- d: Number of day in month.
- HH: Zero-padded 24 hour time.
- H: 24 hour time.
- hh: Zero-padded 12 hour time.
- h: 12 hour time.
- mm: Zero-padded minutes.
- m: minutes.
- ss: Zero-padded seconds.
- s: Seconds.
- ff: Zero-padded milleseconds, 3 digits.
- f: Milleseconds.
- A: AM/PM.
- a: am/pm.
- Z: Time-zone in ISO8601-compatible format (i.e. “-04:00”).