2.2.1 • Published 6 years ago

date-format-ldml v2.2.1

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Overview

This is a date formatting library based on Steven Levithan's Date Format 1.2.3, that attempts to stay closer to Unicode locale data markup language standard.

Installation and usage

Use npm to get the library and reference it on your HTML page

npm install date-format-ldml

The library is AMD and Commonjs aware, but it can be used without them:

var datetime = new Date(2018, 03 - 1, 1, 14, 20, 31, 123);
console.log(dateFormat(datetime, "yyyy MM dd HH:mm:ss - L"));

2018 03 01 14:20:31 - 12

Masks

Initial masks were changed to stay closer to the unicode standard. Here is the table of all supported characters:

MaskDescription
dDay of the month as digits; no leading zero for single-digit days
ddDay of the month as digits; leading zero for single-digit days
DDay of the year as digits; no leading zero for single-digit days
DDDay of the year as digits; leading zero for single-digit days
DDDDay of the year as digits; two leading zeroes for two-digit days
EDay of the week as a three-letter abbreviation
EEDay of the week as a three-letter abbreviation
EEEDay of the week as a three-letter abbreviation
EEEEDay of the week as its full name
eDay of the week as digits; no leading zero for single-digit days. Monday is 1, Sunday is 7
eeDay of the week as digits; leading zero for single-digit days. Monday is 01, Sunday is 07
eeeDay of the week as a three-letter abbreviation
eeeeDay of the week as its full name
MMonth as digits; no leading zero for single-digit months
MMMonth as digits; leading zero for single-digit months
MMMMonth as a three-letter abbreviation
MMMMMonth as its full name
yYear represented by four digits
yyYear as last two digits; leading zero for years less than 10
yyyYear as last three digits; two leading zeroes for years less than 10
yyyyYear represented by four digits
QQQQuarter. Q1, Q2, Q3, Q4
wWeek of year as digits according to ISO 8601; no leading zero for single-digit weeks
wwWeek of year as digits according to ISO 8601; leading zero for single-digit weeks
hHours; no leading zero for single-digit hours (12-hour clock)
hhHours; leading zero for single-digit hours (12-hour clock)
HHours; no leading zero for single-digit hours (24-hour clock)
HHHours; leading zero for single-digit hours (24-hour clock)
mMinutes; no leading zero for single-digit minutes
mmMinutes; leading zero for single-digit minutes
sSeconds; no leading zero for single-digit seconds
ssSeconds; leading zero for single-digit seconds
l or LMilliseconds. l gives 3 digits. L gives 2 digits
aAM or PM
ZGMT/UTC timezone offset, e.g. -0500 or +0230
ZZZZThe long localized GMT format, e.g. GMT-5:00
SThe date's ordinal suffix (st, nd, rd, or th). Works well with d
'…'or"…"Literal character sequence. Surrounding quotes are removed
UTC:Must be the first four characters of the mask. Converts the date from local time to UTC/GMT/Zulu time before applying the mask. The "UTC:" prefix is removed
2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago