1

Possible Duplicate:
NSString to NSDate
iPhone: How to convert “yyyyMMddThhmmss” format string to NSDate?

How do I convert this format to NSDate ?

My string date format is: yyyy-m-d'T'H:m:ss (no space between intervals).

Update:

2012-11-06T12:17:22.947 would be the string that I'd like to convert to NSDate
Community
  • 1
  • 1
el.severo
  • 2,202
  • 6
  • 31
  • 62

1 Answers1

6

just paste this method in your .m file and then call this method with your stringDate..

-(NSDate *)convertStringToDate:(NSString *) date {

NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
NSDate *nowDate = [[[NSDate alloc] init] autorelease];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
date = [date stringByReplacingOccurrencesOfString:@"+0000" withString:@""];
nowDate = [formatter dateFromString:date];
// NSLog(@"date============================>>>>>>>>>>>>>>> : %@", nowDate);
return nowDate;

}
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70