objective c - Get last time with period in iPhone 4 with NSDateFormatter -
i have problem method:
-(nsstring *)getlasttimemessagewithperiod:(nsdate*)lastmessagedate { nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"h:mm a"]; nsstring *resultstring = [dateformatter stringfromdate: lastmessagedate]; return resultstring; }
in iphone 4 (ios 7.1 ) resultstring return " 12:32 "
in iphone 5 (ios 8 ) resultstring return " 12:32 "
what can problem makes miss period in iphone 4 ?
i've tested provided code on ios 7.1 device, , gave me "3:22", problem not device or os version.
problem locale, , work
- (nsstring *)getlasttimemessagewithperiod:(nsdate *)lastmessagedate { nsdateformatter *dateformatter = [nsdateformatter new]; [dateformatter setdateformat:@"h:mm a"]; [dateformatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us_posix"]]; return [dateformatter stringfromdate:lastmessagedate];; }
Comments
Post a Comment