user1337645
user1337645

Reputation: 473

creating NSDate from format

What is the NSFormat required for a string like this?

Fri, 15 Jun 2012 15:37:38 GMT

I'm trying to create a NSDate object from it. thanks

Upvotes: 3

Views: 260

Answers (1)

Omar Abdelhafith
Omar Abdelhafith

Reputation: 21221

Use the following

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss z"];
NSDate *date = [formatter dateFromString:@"Fri, 15 Jun 2012 15:37:38 GMT"];
NSLog([date description]); //2012-06-15 15:37:38 +0000

Upvotes: 4

Related Questions