views:

362

answers:

1

Hi, i am new to iphone development. In my input date format is "2010-03-05T18:20:40Z", and i donno to how to give a input format of my code.So i have mentioned in my code (?).

input date format = "2010-03-05T18:20:40Z"

Here my code is:

NSString *indate = @"2010-03-05T18:20:40Z";
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"????????????????????????"];

NSDate *inputDate = [inputFormatter dateFromString:indate];
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"EEE. MMM. d, yyyy"];

NSString *outputDate = [outputFormatter stringFromDate:inputDate];  

lDate.text = outputDate;

Plz help me out.

Thanks.

+3  A: 

try this out http://stackoverflow.com/questions/936969/nsdate-and-nsdateformatter-short-format-date-and-time-in-iphone-sdk

"yyyy-MM-dd'T'HH:mm:ss'Z'"
zapping
Hi man, it works fine. Thanks a lot.....
Pugal Devan
@zapping "Mon, 22 Jun 2009 12:00:00 GMT", for the above format how should i give input format?, i donno for GMT.
Pugal Devan
@Pugal this should do it "EEE, dd MMM yyyy HH:mm:ss zzzz".
zapping
Thank you very much... It works perfectly. Is there any reference documents are available for the date formats?. Thanks.
Pugal Devan
http://developer.apple.com/iphone/library/DOCUMENTATION/Cocoa/Conceptual/DataFormatting/Articles/df100103.htmlhttp://iphonedevelopertips.com/cocoa/date-formatters-examples-take-2.html
zapping
http://iphonedevelopertips.com/cocoa/date-formatters-examples-take-2.html
zapping