1. Get the HTTP Header
I have defined the global variable mycache of asidownloadcache in appdelegate.
Appdelegate * appdelegate = [[uiapplication sharedapplication] Delegate]; nsdictionary * DIC = [appdelegate. mycache cachedresponseheadersforurl: [nsurl urlwithstring: @ "http ://...... /getpicturenews. aspx "];
Output DIC And get the following result:
{"Cache-control" = private; "Content-Length" = 2404; "Content-Type" = "text/html; charset = UTF-8"; Date = "Sun, 07 Oct 2012 06:13:41 GMT "; server =" Microsoft-IIS/6.0 ";" X-asihttprequest-fetch-Date "=" Sun, 07 Oct 2012 06:13:44 GMT "; "X-ASPnet-version" = "2.0.50727"; "X-powered-by" = "ASP. net ";}
2. Get date and convert
Nsstring * lastupdate = [DIC objectforkey: @ "date"]; nsdateformatter * formatter = [[nsdateformatter alloc] init]; [formatter setdateformat: @ "eee ', 'dd' 'mmm' 'yyyy HH ': 'mm': 'ss Zzz "]; nsdate * Date = [formatter datefromstring: lastupdate]; nslog (@" % @", date );
The output date is
06:13:44 + 0000
3. Summary
The key is that the formatter string of nsdateformatter should be correctly written, and other things can be done after the date is obtained. There is no difference in performing other date operations.