iphone - How to format Facebook/Twitter dates (from the JSON feed) in Objective-C -


for iphone application...

i looking way format facebook created_time json property value.

"created_time": "2010-12-01t21:35:43+0000"

i looking way format twitter date.

"created_at": "wed dec 01 17:08:03 +0000 2010"

i wish change both in format of thu nov 18, 2010 06:48 am, or similar. have had no luck using nsdateformatter.

how can format these dates facebook , twitter using objective-c format desire?

here have working twitter:

nsdateformatter *df = [[[nsdateformatter alloc] init] autorelease];     //wed dec 01 17:08:03 +0000 2010     [df setdateformat:@"eee mmm dd hh:mm:ss zzzz yyyy"];     nsdate *date = [df datefromstring:[[tweets objectatindex: storyindex] objectforkey: twitter_created_at_json_key]];     [df setdateformat:@"eee mmm dd yyyy"];     nsstring *datestr = [df stringfromdate:date]; 

where tweets nsmutablearray filled nsdictionary objects, storyindex being row int value (in tableview), , twitter_created_at_json_key being constant nsstring value created_at. use datestr wherever wish display date

and facebook:

nsdateformatter *df = [[[nsdateformatter alloc] init] autorelease];     //2010-12-01t21:35:43+0000       [df setdateformat:@"yyyy-mm-dd't'hh:mm:sszzzz"];     nsdate *date = [df datefromstring:[[facebook objectforkey:facebook_post_created_time_json_key] stringbyreplacingoccurrencesofstring:@"t" withstring:@""]];     [df setdateformat:@"eee mmm dd, yyyy hh:mm"];     nsstring *datestr = [df stringfromdate:date]; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -