6

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.

Pugalmuni
  • 9,210
  • 8
  • 52
  • 95

1 Answers1

3

try this out Formatting NSDate into particular styles for both year, month, day, and hour, minute, seconds

"yyyy-MM-dd'T'HH:mm:ss'Z'"
Community
  • 1
  • 1
zapping
  • 3,963
  • 6
  • 38
  • 54
  • @zapping "Mon, 22 Jun 2009 12:00:00 GMT", for the above format how should i give input format?, i donno for GMT. – Pugalmuni Apr 08 '10 at 11:55
  • 1
    @Pugal this should do it "EEE, dd MMM yyyy HH:mm:ss zzzz". – zapping Apr 08 '10 at 12:31
  • Thank you very much... It works perfectly. Is there any reference documents are available for the date formats?. Thanks. – Pugalmuni Apr 08 '10 at 12:44
  • 1
    http://developer.apple.com/iphone/library/DOCUMENTATION/Cocoa/Conceptual/DataFormatting/Articles/df100103.html http://iphonedevelopertips.com/cocoa/date-formatters-examples-take-2.html – zapping Apr 08 '10 at 13:12