Date Formatting in iphone
I am having a date as 2010-08-02 开发者_开发技巧which is 2nd August 2010 now i want to dispaly this as Monday,8 August ,2010
Thanks for the helpYou should take a look at NSDateFormatter and if neccessary create your own formatter from a String like in the second link (The last listing).
http://developer.apple.com/iphone/library/documentation/cocoa/reference/foundation/Classes/NSDateFormatter_Class/Reference/Reference.html
http://developer.apple.com/iphone/library/documentation/cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"yyyy-MM-dd"];
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"EEEE',' d MMMM yyyy"];
NSDate *date = [inputFormatter dateFromString:@"2010-08-02"];
NSString *dateString = [outputFormatter stringFromDate:date];
NSLog(@"%@", dateString);
[inputFormatter release];
[outputFormatter release];
精彩评论