iphone - NSDateFormatter not working properly with UTC -
i have following date: 2011-04-29t14:54:00-04:00
when runs through following code convert date, date null reason:
nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"yyyy-mm-dd't'hh:mm:ssz"]; nsdate *date = [dateformatter datefromstring:localdate]; [dateformatter release]; nsdateformatter *formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"yyyy-mm-dd"]; nslog(@"%@", [formatter stringfromdate:date]);
any appreciated
solved:
ok, figured out. reason, method doesn't work.
nsdate *date = [dateformatter datefromstring:localdate];
this works instead. hope helps someone!
nserror *error = nil; nsdate *date = nil; [dateformatter getobjectvalue:&date forstring:localdate range:nil error:&error];
ok, figured out. reason, method doesn't work.
nsdate *date = [dateformatter datefromstring:localdate];
this works instead. hope helps someone!
nserror *error = nil; nsdate *date = nil; [dateformatter getobjectvalue:&date forstring:localdate range:nil error:&error];
Comments
Post a Comment