Super-Easy Date Formatting in Objective-C [#iosdev]

Available since iOS 4, the localizedStringFromDate:dateStyle:timeStyleclass method provides an extremely convenient way of formatting a date as a string. All you have to do is provide your NSDate object that you wish to convert, and pass the appropriate NSDateFormatterStyle value for the types of formats you would like for your date and time parts of the date. If you use NSDateFormatterNoStyle then the particular part will not be rendered. The other good news is that it’s generating a localized string, so the format is taken care of by the framework, which, honestly, is exactly how it should work in the first place.
[NSDateFormatter localizedStringFromDate:myDate
The generates “3/22/13” in my locale (US), but if I switch my device to Portugal, for instance (of course), the date becomes “21/03/13”.
Here’s a link to the Apple Developer Docs.