I have the following code:
[ [NSDate date] descriptionWithLocale: @"yyyy-MM-dd" ]
I want it to return a date in the following format: “2009-04-23”
But it returns: Thursday, April 23, 2009 11:27:03 PM GMT+03:00
What am I doing wrong?
Thank you in advance.
You are using the wrong method. Instead try
descriptionWithCalendarFormat:timeZone:locale:Also note that the method is expecting a different format than the one in your question. The full documentation for that can be found here.
EDIT: Though as Mike noted, you really should be using
NSDateFormatter. There are some problems withdescriptionWithCalendarFormat:timezone:locale:that Apple mentions in the documentation.