Common time formats

Introduction

Date formatting tokens differ by tool: strftime for Ruby and date, Moment.js tokens for JavaScript libraries that copy them.

strftime format

Presets

Date

ExampleOutput
%m/%d/%Y06/05/2013
%A, %B %e, %YWednesday, June 5, 2013
%F2013-06-05
%b %e %aJun 5 Wed

Time

ExampleOutput
%H:%M23:05
%I:%M %p11:05 PM
%T23:05:00

Used by Ruby, UNIX date, and many more.

See: strftime

Date

SymbolExampleArea
%aSunWeekday
%ASunday 
%w0..6 (Sunday is 0) 
%y13Year
%Y2013 
%bJanMonth
%BJanuary 
%m01..12 
%d01..31Day
%e1..31 

See: strftime

Time

SymbolExampleArea
%l1Hour
%H00..2324h hour
%I01..1212h hour
%M00..59Minute
%S00..60Second
%pAMAM or PM
%ZUTCZone name
%z+0000Numeric offset
%j001..366Day of the year
%s1370473500Epoch seconds
%%%Literal % character

See: strftime

Moment.js format

Examples

Date

ExampleOutput
YYYY-MM-DD2014-01-01
dddd, MMMM Do YYYYFriday, May 16th 2014
dddd [the] Do [of] MMMMFriday the 16th of May

Time

ExampleOutput
hh:mm a12:30 pm

Moment.js tokens; date-fns and Java SimpleDateFormat use different ones. Moment itself is in maintenance mode.

See: Format

Date

SymbolExampleArea
d0..6Weekday
ddSu 
dddSun 
ddddSunday 
YY13Year
YYYY2013 
M1..12 (Jan is 1)Month
Mo1st..12th 
MM01..12 (Jan is 1) 
MMMJan 
MMMMJanuary 
Q1..4Quarter
Qo1st..4th 
D1..31Day
Do1st..31st 
DD01..31 
DDD1..365Day of year
DDDo1st..365th 
DDDD001..365 
w1..53Week of year
wo1st..53rd 
ww01..53 

See: Format

Time

SymbolExampleArea
H0..2324h hour
HH00..23 
h1..1212h hour
hh01..12 
m0..59Minutes
mm00..59 
s0..59Seconds
ss00..59 
aamAM/PM
AAM 
Z+07:00Zone offset
ZZ+0730 
S0..9Deciseconds
SS00..99Centiseconds
SSS000..999Milliseconds
X1360013296Unix timestamp
x1360013296123Unix ms timestamp

See: Format

Presets

ExampleOutput
LT8:30 PM
LTS8:30:25 PM
LLAugust 2, 1985
llAug 2, 1985
LLLAugust 2, 1985 8:30 PM
lllAug 2, 1985 8:30 PM
LLLLFriday, August 2, 1985 8:30 PM
llllFri, Aug 2, 1985 8:30 PM

See: Long date formats

0 Comments for this cheatsheet. Write yours!