Hi, Is the date Format "dd.mm.yyyy" available?
let dateFormatter = DateFormatter()
dateFormatter.calendar = Calendar.current
dateFormatter.dateFormat = "dd.MM.yyyy"
Do not write code like this. The problem here is that you’re using the current calendar, which may not be Gregorian, and thus you may get results that are wildly wrong. See QA1480 NSDateFormatter and Internet Dates for a concrete example of how this can end badly.
You have two choices here:
-
If you’re working with a fixed-format date — for example, parsing a date that’s returned from a server — either pin the locale to
en_US_POSIX
(see QA1480) or useNSISO8601DateFormatter
. -
If you’re working with a localised date — one that you display to the user — either set the
dateStyle
to one of the standard styles or callsetLocalizedDateFormatFromTemplate(_:)
.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"