views:

137

answers:

1

I'm working with Objective C for iPhone and have a NSDate that I want to display in full style but without the year. Right now I'm using the code below but it also show the year, and I don't want that. As I want to show the date in the right region format I cannot just delete the year in the end as in some countries the year will not be in the end but in the middle or beginning.

NSDate *testdate = [NSDate date];
NSDateFormatter *dateFormattertest = [[NSDateFormatter alloc] init];
[dateFormattertest setDateStyle:NSDateFormatterFullStyle];
[dateFormattertest setTimeStyle:NSDateFormatterNoStyle];
NSString *formattedDateString = [dateFormattertest stringFromDate:testdate];
NSLog(formattedDateString);

In US this give me:
Thursday, January 14, 2010

In Sweden this give me:
torsdag, 2010 januari 14

What is the solution for this? And another question, where can I find information on how to use the setDateFormat of NSDateFormatter? I can't find information about what different letters stand for in the API.

A: 

You can consult this article for the information you are seeking:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369

Tomen
I can't see from this text how I should get the result in full style but without hours?
Martin
you would use setDateFormat to set your specific format. For information on how to format the date, you can also read: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DataFormatting/Articles/df100103.html#//apple_ref/doc/uid/TP40007972-SW9
Tomen