objective c - formatting dates so users can read it iOS -


i trying convert

2015-05-16t08:00:00.000-07:00

into format: may 16th, 2015 7pm -8pm

can please show me how can change above format in objective c?

thank you!

i think have use custom method this, please check below method may -

-(nsstring*) getdatetimeinstring:(nsdate*)date     {         nsstring* string=@"";         nsdatecomponents *components = [[nscalendar currentcalendar] components: nscalendarunitday fromdate:date];          if(components.day == 1 || components.day == 21 || components.day == 31){              string = @"st";         }else if (components.day == 2 || components.day == 22){             string = @"nd";         }else if (components.day == 3 || components.day == 23){              string = @"rd";         }else{              string = @"th";         }          nsdateformatter *prefixdateformatter = [[nsdateformatter alloc] init];    [prefixdateformatter setformatterbehavior:nsdateformatterbehavior10_4];           [prefixdateformatter setdateformat:[nsstring stringwithformat:@"mmm d'%@', yyyy hh a,string]];          nsstring *datestring = [prefixdateformatter stringfromdate:date];          return datestring;     } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -