Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 661
user1337645 Avatar asked Mar 25 '26 04:03

user1337645


1 Answers

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
like image 136
Omar Abdelhafith Avatar answered Mar 27 '26 23:03

Omar Abdelhafith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!