objective c - NSDate issue with locale -


i'm working on ipad app speaks private php api built communicate database. api has transfer 3 dates, starting time, end time , current time.

i want test if current time in-between date range. took times (like 16:50:00) , convert them nsdates:

nsdateformatter *former = [[nsdateformatter alloc] init]; [former setdateformat:@"hh:mm:ss"]; [former setlocale:[nslocale currentlocale]];  nsdate *fromdate = [former datefromstring:@"10:15:00"]; nsdate *nowdate = [former datefromstring:@"13:25:00"]; nsdate *todate = [former datefromstring:@"16:30:00"]; 

when i'm logging dates using nslog(@"\n%@\n%@\n%@", fromdate, nowdate, todate); see locale incorrect.

it seems nsdateformatter ignores locale setting. logged currentlocales identifier right 1 ("de_de" in case"). locale remains +0000.

how can fix issue? thanks, kind regards, julian

alright, i've removed previous answer, try following

nsdateformatter *formatter = [[nsdateformatter alloc] init]; nstimezone *zone = [nstimezone localtimezone]; [formatter settimezone:zone]; [formatter setdateformat:@"hh:mm:ss"];  nsdate *date = [formatter datefromstring:@"10:15:00"];  nslog(@"time %@",[formatter stringfromdate:date]); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -