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
yDisplays the year (0-9) as a number without leading zeros
yyDisplays the year in a two-digit number format with leading zeros
yyyDisplays the year in four-digit number format
yyyyDisplays the year in four-digit number format
-
Month
MDisplays the month as a number without a leading zero (for example, January is represented as 1)
MMDisplays the month as a number with leading zeros (such as 01/12/01)
MMMDisplay the month as an abbreviated form (such as Jan)
MMMMDisplay 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
dDisplays the day as a number without leading zeros (such as 1)
ddDisplays the day as a number with leading zeros (for example, 01)
- Week
EEEDisplay the day as an abbreviated form (e.g. Sun)
EEEEDisplay 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
hDisplays the hour as a number without leading zeros using the 12-hour system (e.g. 1:15:15 PM)
hhUse a 12-hour system to display the hour as a number with leading zeros (such as 01:15:15 PM)
HDisplays the hour as a number without leading zeros using a 24-hour system (e.g. 1:15:15)
HHDisplays the hour as a number with leading zeros using a 24-hour system (e.g. 01:15:15)
- Minutes
mShow minutes as numbers without leading zeros (such as 12:1:15)
mmDisplays the minute as a number with leading zeros (for example, 12:01:15)
- Seconds
sDisplays the seconds as a number without leading zeros (such as 12:15:5)
ssDisplays seconds as a number with leading zeros (for example, 12:15:05)
fDisplays the decimal part of the second
ffwill be accurately displayed to one second of the percentage
ffffwill be displayed exactly one second in the extreme.
- Up to seven F symbols can be used in a user-defined format
- Morning & Afternoon
tUsing the 12-hour system
- Show uppercase A for any hour before noon
- Any hour between noon and 11:59 to show the uppercase P
ttFor 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
zDisplays the time zone offset without leading zeros
zzDisplays the time zone offset with leading zeros (e.g.-08)
zzzDisplays the full time zone offset (e.g.-0800)
- Era
ggDisplays the era/era string (such as A.D.)
Summary of NSDateFormatter date format parsing in iOS development