Search code examples
cocoacocoa-touchnsdateformatter

Get the local date format as a string


I want a method that returns the local date format as a string.

E.g., the method would return the string "dd/MM/yyyy" for UK users and "MM/dd/yyyy" for USA users.


Solution

  • What you are looking for is NSDateFormatter's dateFormatFromTemplate:options:locale: method. This takes a template containing the elements of the date you wish included and returns the appropriate format for the supplied locale.