-1

Possible Duplicate:
Converting NSString to NSDate (and back again)

How to convert this NSString(Tue, 13 Mar 2012 00:00:00 -0500) into NSDate format

Community
  • 1
  • 1
user1268135
  • 57
  • 1
  • 7
  • You need to refer to http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/ – Parth Bhatt Mar 15 '12 at 07:08
  • You also need to refer to: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DataFormatting/Articles/dfNumberFormatting10_4.html – Parth Bhatt Mar 15 '12 at 07:12

2 Answers2

1

NSDateFormatter uses the Unicode Date Format Patterns.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZZ"];

NSDate *date = [dateFormatter dateFromString:stringDate ];
[dateFormatter release];
Deepesh
  • 8,065
  • 3
  • 28
  • 45
0

Try this

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"eee, dd MMM yyyy HH:mm:ss ZZZ"];
NSDate *dateFromString = [[NSDate alloc] init] ;
dateFromString = [dateFormatter dateFromString:str];
[dateFormatter release];
Dhara
  • 4,093
  • 2
  • 36
  • 69