NSDate

suggest change

Syntax

Remarks

There are different types of date format that you can set: Here is full list of them.

|Format | Meaning/Description | Example1 | Example2 | | —— | —— | –– | ––| | y | A year with at least 1 digit. | 175 AD → “175” | 2016 AD → “2016”| | yy | A year with exactly 2 digits. | 5 AD → “05” | 2016 AD → “16” | | yyy | A year with at least 3 digits. | 5 AD → “005” | 2016 AD → “2016” | | yyyy | A year with at least 4 digits. | 5 AD → “0005” | 2016 AD → “2016” | | M | A month with at least 1 digit. | July → “7” | “November” → “11”| | MM | A month with at least 2 digits. | July → “07” | “November” → “11”| | MMM | Three letter month abbreviation. | July → “Jul” | “November” → “Nov”| | MMMM | Full name of month. | July → “July” | “November” → “November”| | MMMMM | One letter month abbreviation(Jan,June,July all will have ‘J’). | July → “J” | “November” → “N”| | d | Day with at least one digit. | 8 → “8” | 29 → “29” | | dd | Day with at least two digits. | 8 → “08” | 29 → “29” | | “E”, “EE”, or”EEE” | 3 letter day abbreviation of day name. | Monday → “Mon” | Thursday → “Thu” | | EEEE | Full Day name. | Monday → “Monday” | Thursday → “Thursday” | | EEEEE | 1 letter day abbreviation of day name.(Thu and Tue will be ‘T’) | Monday → “M” | Thursday → “T” | | EEEEEE | 2 letter day abbreviation of day name. | Monday → “Mo” | Thursday → “Th” | | a | Period of day (AM/PM). | 10 PM → “PM” | 2 AM → “AM” | | h | A 1-12 based hour with at least 1 digit. | 10 PM → “10” | 2 AM → “2” | | hh | A 1-12 based hour with at least 2 digits. | 10 PM → “10” | 2 AM → “02” | | H | A 0-23 based hour with at least 1 digit. | 10 PM → “14” | 2 AM → “2” | | HH | A 0-23 based hour with at least 2 digits. | 10 PM → “14” | 2 AM → “02” | | m | A minute with at least 1 digit. | 7 → “7” | 29 → “29” | | mm | A minute with at least 2 digits. | 7 → “07” | 29 → “29” | | s | A second with at least 1 digit. | 7 → “7” | 29 → “29” | | ss | A second with at least 2 digits. | 7 → “07” | 29 → “29” |

There are many more, for getting different time based on zone(z), for getting time with millisecond details(S), etc.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents