ios - Xcode Date Formatting - Format from RSS -


i have trouble this, , keep seem find resource learn exhaustively. trying use date formatter in xcode objective c, not setting date format correctly. here data:

fri, 27 jun 2014 12:33:18 +0000 

can assist me or point me in right direction? trying below code, not working.

nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us"]]; [dateformatter setdateformat:@"eee, d lll yyyy hh:mm:ss z"]; 

update: format below might help, shows 0 padding on day.

wed, 02 jul 2014 11:47:35 +0000 

according unicode technical standard #35, "lll" date format "stand-alone month" "a month name without associated day number". should use "mmm" instead:

[dateformatter setdateformat:@"eee, d mmm yyyy hh:mm:ss z"]; 

example:

nsstring *str = @"fri, 27 jun 2014 12:33:18 +0000"; nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us"]]; [dateformatter setdateformat:@"eee, d mmm yyyy hh:mm:ss z"]; nsdate *date = [dateformatter datefromstring:str]; nslog(@"%@", date); // output: 2014-06-27 12:33:18 +0000 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -