ios - How to parse a string to date using dateformatter in objective c -
i have string '2015-06-23t15:43:04.000+05:30' , want convert date format 23 june 2015 15:43
try one's:
nsstring *temp = @"2015-06-23t15:43:04.000+05:30"; nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"yyyy-mm-dd't'hh:mm:ss.sss'+05:30'"]; nsdate *dte = [dateformat datefromstring:temp]; nslog(@"date: %@", dte); nsdateformatter *df = [[nsdateformatter alloc] init]; [df setdateformat:@"dd mmmm yyyy hh:mm"]; nslog(@"%@", [df stringfromdate:dte]);
in console:
date: 2015-06-23 12:43:04 +0000
23 june 2015 15:43
Comments
Post a Comment