ios - NSDate different in simulator and device(ipad) -
hi converting gmt time local time in project - getting correct value in simulator , in iphone/ipod - when run in ipad getting null, here code -
nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; dateformatter.dateformat = @"hh:mm:ss"; nstimezone *gmt = [nstimezone timezonewithabbreviation:@"gmt"]; [dateformatter settimezone:gmt]; nsdate *startdate = [dateformatter datefromstring:@"14:37:00"]; nslog(@"startdate---%@",startdate); //this startdate---2000-01-01 14:37:00 +0000 (in simulator/ipod/iphone) // startdate---(null) (in ipad)
issue user's ipad's time format - if in 12 hour format - above code results null do issue ??
bacause time format set 12 hours on ipad device, date string in 24 hours format @ string @"14:37:00".
use
dateformatter.dateformat = @"hh:mm:ss"; [dateformatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us"];
if want force 12-hour mode, regardless of user's 24/12 hour mode setting, should set locale en_us_posix.
use hh instead of hh.
hh 12 hour time while hh 24 hour time.
a official reference this, as linked apple themselves, here. table here, mentioned zaph.
Comments
Post a Comment