Ad

NSDateFormatterStyle.MediumStyle Doesn't Show In IPhone

- 1 answer

I'm using NSDateFormatterStyle.MediumStyle in my application to convert the date. I display the date on label with font size of 12

It functions on the

iPad

simulator it show like "nov 12,1994" but on my

iPhone

device it shows short formatter: "11/12/1994".

Do you know why it function on the iPad but not in the iPhone

Ad

Answer

From the NSDateFormatterStyle documentation :

The format for these date and time styles is not exact because they depend on the locale, user preference settings, and the operating system version. Do not use these constants if you want an exact format.

That said, I assume your iPad and your iPhone are set to different locales

If you want your dates to be as per the iPad example above across all locales, you can create your own formatter

let date = NSDate()
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MMM d, yyyy"
dateFormatter.stringFromDate(date)
Ad
source: stackoverflow.com
Ad