Last active
September 1, 2016 14:01
-
-
Save GoNinja/706a601bf411fd426fb211402f7d978c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let formatter = NSDateFormatter() | |
formatter.dateFormat = "y" //A year with at least 1 digit. | |
formatter.dateFormat = "yy" //A year with 2 digits. If less, it is padded with a zero. It will be truncated to the tens digit if larger. | |
formatter.dateFormat = "yyyy" //A year with at least 3 digits. If less, it is padded with zeros. | |
formatter.dateFormat = "yyyy" //A year with at least 3 digits. If less, it is padded with zeros. | |
formatter.dateFormat = "M" //A year with at least 1 digits. | |
formatter.dateFormat = "MM" //A month with at least 2 digits. If less, it is padded with zeros. | |
formatter.dateFormat = "MMM" //Three letter month abbreviation. | |
formatter.dateFormat = "MMMM" //Full name of month. | |
formatter.dateFormat = "MMMMM" //One letter month abbreviation. Not unique, January, June, and July are all “J”. | |
formatter.dateFormat = "d" //A day with at least 1 digit. | |
formatter.dateFormat = "dd" //A day with at least 2 digits. If less, it is padded with a zero. | |
formatter.dateFormat = "E" //Or "EE" or "EEE" 3 letter day abbreviation of day name. | |
formatter.dateFormat = "EEEE" //Full day name. | |
formatter.dateFormat = "EEEEE" //1 letter day abbreviation of day name. Not unique, Tuesday and Thursday are both “T”. | |
formatter.dateFormat = "EEEEEE" //2 letter day abbreviation of day name. | |
formatter.dateFormat = "a" //Period of day (AM/PM). | |
formatter.dateFormat = "h" //A 1-12 based hour with at least 1 digit. | |
formatter.dateFormat = "hh" //A 1-12 based hour with at least 2 digits. If less, it is padded with a zero. | |
formatter.dateFormat = "H" //A 0-23 based hour with at least 1 digit. | |
formatter.dateFormat = "HH" //A 0-23 based hour with at least 2 digits. If less, it is padded with a zero. | |
formatter.dateFormat = "m" //A minute with at least 1 digit. | |
formatter.dateFormat = "mm" //A minute with at least 2 digits. If less, it is padded with a zero. | |
formatter.dateFormat = "s" //A second with at least 2 digits. If less, it is padded with a zero. | |
formatter.dateFormat = "S" //Tenths place of fractional second. | |
formatter.dateFormat = "SS" //Tenths and hundredths place of a fractional second. | |
formatter.dateFormat = "SSS" //Tenths, hundredths, and thousandths place of a fractional second. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment