Created
September 9, 2017 22:03
-
-
Save tsraveling/42cafc58caa45c010ff941774555486b to your computer and use it in GitHub Desktop.
Date Formatter
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 globalDateFormatter : DateFormatter = { | |
| let df = DateFormatter() | |
| df.dateFormat = "MMMM d, yyyy" | |
| return df | |
| }() | |
| extension Date { | |
| static func fromString(_ source : String) -> Date? { | |
| return globalDateFormatter.date(from: source) | |
| } | |
| func format() -> String { | |
| return globalDateFormatter.string(from: self) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment