Created
July 4, 2016 12:50
-
-
Save LeonardoCardoso/30f830e09582db386460e4de408fd439 to your computer and use it in GitHub Desktop.
Convert date from a format to another
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
extension String { | |
func convertDateDFormat(from: String = "yyyy-mm-dd", to: String = "EEE dd/mm/yyyy") -> String! { | |
let dateOriginalFormat = NSDateFormatter() | |
dateOriginalFormat.dateFormat = from | |
let dateDestinationFormat = NSDateFormatter() | |
dateDestinationFormat.dateFormat = to | |
let dateFromString = dateOriginalFormat.dateFromString(self) | |
let dateFormated = dateDestinationFormat.stringFromDate(dateFromString!) | |
return dateFormated | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment