NSDateFormatter format strings

Guides By 5 years ago

Every time I bookmark one of these lists it seems to disappear soon after, so it’s time to make my own (laid out to my liking):

FormatDescriptionAllows 0 paddingExample
AMillisecond of Day0-86399999
hHour (12hr)1-12
HHour (24hr)0-24
dDay of Month1-31
DDay of Year1-366
cDay of WeekX1-7
cccDay of Week (Abbreviated)XSun/Mon/Tue…
ccccDay of WeekXSunday/Monday/…
WWeek of Month1-5
wWeek of Year1-53
MMMMonth (Abbreviated)XJan/Feb/Mar…
yyYear (2 digits)X12/13/…
qqqQuarter (short)XQ1/Q2/Q3/Q4
qqqqQuarter (long)1st quarter/2nd…
gJulian Day (days since 4713 BC)2456200
GEra (Abbreviated)XBC/AD
GGGGEraXBefore Christ/
Anno Domini
vGeneral Timezone (Abbreviated)XAET
vvvvGeneral TimezoneXEastern Australia Time
zTimezone (Abbreviated)XAEDT
zzzzTimezoneXAustralian Eastern Daylight Time
ZGMT OffsetX+1100
  • cwagdev

    Thank you! I have the same experience.

  • Yea, same here. Thanks for doing this. I’ve bookmarked it now, hopefully this won’t disappear aswell…

  • Rainier Wolfcastle

    Why on earth have Apple NOT added this to the documentation? And if it’s there, why in God’s name can’t I find it? Apple’s docs are horrible!