In the work, often encountered to convert time to their own corresponding requirements of the time format, before the collection of the corresponding conversion format, now will be part of their own collection to do a share, should be more intact, welcome you continue to add
- Years
y
Displays the year (0-9) as a number without leading zeros
yy
Displays the year in a two-digit number format with leading zeros
yyy
Displays the year in four-digit number format
yyyy
Displays the year in four-digit number format
Month
M
Displays the month as a number without a leading zero (for example, January is represented as 1)
MM
Displays the month as a number with leading zeros (such as 01/12/01)
MMM
Display the month as an abbreviated form (such as Jan)
MMMM
Display month as full month name (e.g. January)
- January Jan January
- February Feb February
- March Mar March
- April APR April
- May May
- June June June
- July Jul July
- August August
- September SEP September
- October OCT October
- November Nov November
- December Dec December
Day
d
Displays the day as a number without leading zeros (such as 1)
dd
Displays the day as a number with leading zeros (for example, 01)
- Week
EEE
Display the day as an abbreviated form (e.g. Sun)
EEEE
Display day as full name (e.g. Sunday)
- Monday Mon Monday
- Tuesday Tue Tuesday
- Wednesday Wed Wednesday
- Thursday Thu Thursday
- Friday Fri Friday
- Saturday Sat Saturday
- Sunday Sun Sunday
- Hours
h
Displays the hour as a number without leading zeros using the 12-hour system (e.g. 1:15:15 PM)
hh
Use a 12-hour system to display the hour as a number with leading zeros (such as 01:15:15 PM)
H
Displays the hour as a number without leading zeros using a 24-hour system (e.g. 1:15:15)
HH
Displays the hour as a number with leading zeros using a 24-hour system (e.g. 01:15:15)
- Minutes
m
Show minutes as numbers without leading zeros (such as 12:1:15)
mm
Displays the minute as a number with leading zeros (for example, 12:01:15)
- Seconds
s
Displays the seconds as a number without leading zeros (such as 12:15:5)
ss
Displays seconds as a number with leading zeros (for example, 12:15:05)
f
Displays the decimal part of the second
ff
will be accurately displayed to one second of the percentage
ffff
will be displayed exactly one second in the extreme.
- Up to seven F symbols can be used in a user-defined format
- Morning & Afternoon
t
Using the 12-hour system
- Show uppercase A for any hour before noon
- Any hour between noon and 11:59 to show the uppercase P
tt
For locales that use the 12-hour format
- Show uppercase AM at any hour before noon
- Noon to 11:59 pm to show uppercase PM in any hour
- For locales that use the 24-hour format. Do not display no matter what character
- Time
z
Displays the time zone offset without leading zeros
zz
Displays the time zone offset with leading zeros (e.g.-08)
zzz
Displays the full time zone offset (e.g.-0800)
- Era
gg
Displays the era/era string (such as A.D.)
Summary of NSDateFormatter date format parsing in iOS development