ios - Convert DateTime in iphone -


i need convert current date time "04/10/2013 12:00:00 gmt+5:00" format. had gone through differet methods couldn't got exact format. can know please me.

// string date conversion nsstring *datestr = @"5/13/2012 6:05 am"; nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"m/d/yyyy h:mm a"]; nsdate *mydate = [dateformatter datefromstring:datestr];  // converts time gmt local timezone     nsdateformatter* df_local = [[[nsdateformatter alloc] init] autorelease]; // calculate number of seconds upto 5hrs(gmt+5000) seconds = 18000, if gmt+0530 seconds = 19800 // set timezone accordingly [df_local settimezone:[nstimezone timezoneforsecondsfromgmt:18000]]; // set date formate [df_local setdateformat:@"mm/dd/yyyy hh:mm:ss"];  // final output string nsstring* ts_local_string = [nsstring stringwithformat:@"%@ %@",[df_local stringfromdate:mydate],[[df_local timezone] name]]; nslog(@"final string : %@",ts_local_string);  nsstring* anotherformat = [nsstring stringwithformat:@"%@ %@",[df_local stringfromdate:mydate],[[df_local timezone] abbreviation]]; nslog(@"output : %@",anotherformat); 

output : final string : 05/13/2012 05:35:00 gmt+0500


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -