Characters for formatting a dateTime as String

Source
 

Symbol Meaning Presentation Examples
a am or pm marker Text Input am, AM, pm, PM.

Output AM or PM

d day in month (1-31) Number 1, 20
dd day in month (01-31) Number 01, 31
D day in year (1-366) Number 3, 80, 100
DD day in year (01-366) Number 03, 80, 366
DDD day in year (001-366) Number 3
e day in week (1-7)1 Number 2
EEE day in week1 Text Tue
EEEE day in week1 Text Tuesday
F day of week in month (1-5) Number 2
G Era Text BC or AD
h hour in am or pm (1-12) Number 6
hh hour in am or pm (01-12) Number 6
H hour of day in 24 hour form (0-23) Number 7
HH hour of day in 24 hour form (00-23) Number 7
I ISO8601 Date/Time

(up to yyyy-MM-dd’T’HH:mm:ss. SSSZZZ)

Text 2006-10-07T12:06:56.568+01:00
IU ISO8601 Date/Time

(similar to I, but ZZZ with

Output “Z” if the time zone is +00:00)

Text 2006-10-07T12:06:56.568+01:00,

2003-12 -15T15:42:12.000Z

k hour of day in 24 hour form (1-24) Number 8
kk hour of day in 24 hour form (01-24) Number 8
K hour in am or pm (0-11) Number 9
KK hour in am or pm (00-11) Number 9
m minute Number 4
mm minute Number 4
M numeric month Number 5, 12
MM numeric month Number 05, 12
MMM named month Text Jan, Feb
MMMM named month Text January, February
s seconds Number 5
ss seconds Number 5
S decisecond5 Number 7
SS centisecond5 Number 70
SSS millisecond5 Number 700
SSSS 0.0001 second5 Number 7000
SSSSS 0.00001 second5 Number 70000
SSSSSS 0.000001 second5 Number 700000
T ISO8601 Time (up to HH:mm:ss.SSSZZZ) Text 12:06:56.568+01:00
TU ISO8601 Time

(similar to T, but a time

Zone of +00:00 is replaced with ‘Z’)

Text 12:06:56.568+01:00,

15:42:12.000Z

w week in year Number 7, 53
ww week in year Number 07, 53
W week in month Number 2
yy year Number 6
yyyy year Number 2006
YY year: use with week in year only Number 6
YYYY year: use with week in year only Number 2006
zzz time zone (abbreviated name) Text EST
zzzz time zone (full name) Text Eastern Standard Time
Z time zone (+/-n) Text 3
ZZ time zone (+/-nn) Text 3
ZZZ time zone (+/-nn:nn) Text 03:00:00 AM
ZZZU time zone

(as ZZZ, “+00:00” is replaced by “Z”)

Text +03:00, Z
ZZZZ time zone (GMT+/-nn:nn) Text GMT+03:00
ZZZZZ time zone

(as ZZZ, but no colon) (+/-nnnn)

Text 300
escape for text   User text’
(two single quotation marks)

Single quotation mark within escaped text

 
o”clock’
 
Rate this post

Leave a Reply