Formatting in date-fns

Because I’m so tired of looking it up, here’s the formatting tokens from the excellent date-fns Javascript library. This is limited to the patterns I use most frequently.

UnitPatternResults Example
Calendar yeary44, 1, 1900, 2017
yyyy0044, 0001, 1900, 2017
Month (formatting)M1, 2, …, 12
MM01, 02, …, 12
MMMJan, Feb, …, Dec
MMMMJanuary, February, …, December
Day of monthd1, 2, …, 31
do1st, 2nd, …, 31st
dd01, 02, …, 31
Day of week (formatting)E..EEEMon, Tue, Wed, …, Sun
EEEEMonday, Tuesday, …, Sunday
AM, PMa..aaAM, PM
aaaam, pm
aaaaa.m., p.m.
Hour [1-12]h1, 2, …, 11, 12
hh01, 02, …, 11, 12
Hour [0-23]H0, 1, 2, …, 23
HH00, 01, 02, …, 23
Minutem0, 1, …, 59
mm00, 01, …, 59
Seconds0, 1, …, 59
ss00, 01, …, 59