IOS note, ios note
1. NSDateFormatter format:
- Year
y
Display the year (0-9) as a number without leading zero
yy
Displays the year in the format of two digits with leading zeros.
yyy
Display the year in four-digit format
yyyy
Display the year in four-digit format
Month
M
Display the month as a number without leading zero (for example, January 1, January is expressed as 1)
MM
Display the month as a number with a leading zero (for example, 01/12/01)
MMM
Display the month as an abbreviation (for example, Jan)
MMMM
Display the month as the complete month name (for example, January)
- Jan January
- Feb February
- Mar March, March
- Apr April
- May
- June Jun June
- July Jul July
- Aug August, August
- Sep September
- October, October
- Nov November, November
- December, December
Day
d
Display the day as a number without leading zero (for example, 1)
dd
Display the day as a number with a leading zero (for example, 01)
- Week
EEE
Display Day as an abbreviation (for example, Sun)
EEEE
Display day as full name (for example, Sunday)
- Mon Monday
- Tuesday Tue Tuesday
- Wed Wednesday
- Thu Thursday
- Friday Fri Friday
- Saturday
- Sunday Sun
- Hours
h
Use the 12-hour system to display the hour as a number without leading zero (for example, 1:15:15)
hh
Display the hour as a number with a leading zero (for example, 01:15:15) in 12-hour format)
H
Use the 24-hour system to display the hour as a number without leading zero (for example, 1:15:15)
HH
Display the hour as a number with a leading zero (for example, 01:15:15) in the 24-hour format)
- Minutes
m
Display the minute as a number without leading zero (for example)
mm
Display minutes as numbers with leading zeros (for example, 12:01:15)
- Seconds
s
Display the second as a number without leading zero (for example)
ss
Display seconds as numbers with leading zeros (for example, 12:15:05)
f
Displays the decimal part of a second.
ff
Display to 1% seconds
ffff
Display the data in exactly one thousandth of a second
- Up to seven f characters can be used in user-defined formats
- Morning and afternoon
t
12-hour format
- An upper-case A is displayed for any hour before noon.
- An uppercase P value is displayed for any hour between noon and PM.
tt
For regions in the 12-hour format
- The upper-case AM is displayed for any hour before noon.
- An uppercase PM is displayed for any hour between noon and PM.
- For regions in the 24-hour format, no characters are displayed.
- Time Zone
z
Display Time Zone offset without leading zero
zz
Display the time zone offset with leading zero (for example,-08)
zzz
Display the complete time zone offset (for example,-0800)
- Epoch
gg
Display time/epoch strings (for example, A. D .)