Skip to main content

Format-Date

πŸ“˜ Developer Guide

With the Flyze Format-Date Service, you are able to easily format Date-Objects into valid locale Date-Strings.


πŸ” Example

Runtime

πŸ—οΈ Methods

Method Description Parameters Returns
getDateTimeByFormat Gets a formatted date time date: Date, format: DateFormat, locale?: en | de, timeZone?: TimeZoneOffset Returns an formatted Date-Time String.

locale defaults to active language if no locale is provided

string
getDateTimeByCurrentLanguage Gets a formatted date time by current active language date: Date, format?: DateFormat, timeZone?: TimeZoneOffset Returns an formatted Date-Time String in current active language.

format defaults to fullDate if no format is provided

string
getDateTimeByCurrentLanguage$ Gets a formatted date time by current active language as RXJS-Stream (Observable) date: Date, format?: DateFormat, timeZone?: TimeZoneOffset Returns an formatted Date-Time String in current active language as Observable.

format defaults to fullDate if no format is provided

Observable<string>

✍🏼 Pre-Defined Format Options

OptionEquivalent toExample (en-US locale)
shortM/d/yy, h:mm a6/15/15, 9:03 AM
mediumMMM d, y, h:mm:ss aJun 15, 2015, 9:03:01 AM
longMMMM d, y, h:mm:ss a zJune 15, 2015 at 9:03:01 AM GMT+1
fullEEEE, MMMM d, y, h:mm:ss a zzzzMonday, June 15, 2015 at 9:03:01 AM GMT+01:00
shortDateM/d/yy6/15/15
mediumDateMMM d, yJun 15, 2015
longDateMMMM d, yJune 15, 2015
fullDateEEEE, MMMM d, yMonday, June 15, 2015
shortTimeh:mm a9:03 AM
mediumTimeh:mm:ss a9:03:01 AM
longTimeh:mm:ss a z9:03:01 AM GMT+1
fullTimeh:mm:ss a zzzz9:03:01 AM GMT+01:00

πŸ§‘β€πŸ’» Custom Format Options

Field typeFormatDescriptionExample Value
EraG, GG & GGGAbbreviatedAD
GGGGWideAnno Domini
GGGGGNarrowA
YearyNumeric: minimum digits2, 20, 201, 2017, 20173
yyNumeric: 2 digits + zero padded02, 20, 01, 17, 73
yyyNumeric: 3 digits + zero padded002, 020, 201, 2017, 20173
yyyyNumeric: 4 digits or more + zero padded0002, 0020, 0201, 2017, 20173
ISO Week-numbering yearYNumeric: minimum digits2, 20, 201, 2017, 20173
YYNumeric: 2 digits + zero padded02, 20, 01, 17, 73
YYYNumeric: 3 digits + zero padded002, 020, 201, 2017, 20173
YYYYNumeric: 4 digits or more + zero padded0002, 0020, 0201, 2017, 20173
MonthMNumeric: 1 digit9, 12
MMNumeric: 2 digits + zero padded09, 12
MMMAbbreviatedSep
MMMMWideSeptember
MMMMMNarrowS
Month standaloneLNumeric: 1 digit9, 12
LLNumeric: 2 digits + zero padded09, 12
LLLAbbreviatedSep
LLLLWideSeptember
LLLLLNarrowS
ISO Week of yearwNumeric: minimum digits1... 53
wwNumeric: 2 digits + zero padded01... 53
Week of monthWNumeric: 1 digit1... 5
Day of monthdNumeric: minimum digits1
ddNumeric: 2 digits + zero padded01
Week dayE, EE & EEEAbbreviatedTue
EEEEWideTuesday
EEEEENarrowT
EEEEEEShortTu
Week day standalonec, ccNumeric: 1 digit2
cccAbbreviatedTue
ccccWideTuesday
cccccNarrowT
ccccccShortTu
Perioda, aa & aaaAbbreviatedam/pm or AM/PM
aaaaWide (fallback to a when missing)ante meridiem/post meridiem
aaaaaNarrowa/p
Period*B, BB & BBBAbbreviatedmid.
BBBBWideam, pm, midnight, noon, morning, afternoon, evening, night
BBBBBNarrowmd
Period standalone*b, bb & bbbAbbreviatedmid.
bbbbWideam, pm, midnight, noon, morning, afternoon, evening, night
bbbbbNarrowmd
Hour 1–12hNumeric: minimum digits1, 12
hhNumeric: 2 digits + zero padded01, 12
Hour 0–23HNumeric: minimum digits0, 23
HHNumeric: 2 digits + zero padded00, 23
MinutemNumeric: minimum digits8, 59
mmNumeric: 2 digits + zero padded08, 59
SecondsNumeric: minimum digits0... 59
ssNumeric: 2 digits + zero padded00... 59
Fractional secondsSNumeric: 1 digit0... 9
SSNumeric: 2 digits + zero padded00... 99
SSSNumeric: 3 digits + zero padded (= milliseconds)000... 999
Zonez, zz & zzzShort specific non location format (fallback to O)GMT-8
zzzzLong specific non location format (fallback to OOOO)GMT-08:00
Z, ZZ & ZZZISO8601 basic format-0800
ZZZZLong localized GMT formatGMT-8:00
ZZZZZISO8601 extended format + Z indicator for offset 0-08:00
O, OO & OOOShort localized GMT formatGMT-8
OOOOLong localized GMT formatGMT-08:00