Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - how to get user's date format

How can I know what date format user prefers? Is there a way to read it from phone's local settings? Does the user prefer to read date in format "dd/mm/yyyy" or "mm/dd/yyyy"?

Thank you in advance.

like image 911
Ilya Suzdalnitski Avatar asked Jul 17 '26 00:07

Ilya Suzdalnitski


1 Answers

Use NSDateFormatter, but set the style (not the format) so it uses the user's locale formats.

e.g. create an NSDateFormatter and configure it thusly

[dateFormatter setDateStyle:NSDateFormatterShortStyle];

(for mm/dd/yy type dates, which are dd/mm/yy in other countries)

like image 187
Bwooce Avatar answered Jul 20 '26 00:07

Bwooce



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!