I'm trying to convert a date/time from US to GMT. It does not seem to work probably. It keep returning even null.
int subObjects = ((NSArray *)jsonResult[@"match"]).count;
for (int i = 0; i <= subObjects-1; i++) {
NSString *date = [NSString stringWithFormat:@"%@ %@",[[[jsonResult valueForKey:@"match"] valueForKey:@"playdate"] objectAtIndex:i], [[[jsonResult valueForKey:@"match"] valueForKey:@"time"] objectAtIndex:i]];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setTimeZone: [NSTimeZone timeZoneWithName:@"US/Arizona"]];
[df setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
[df setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]];
NSDate *myDate = [df dateFromString:[NSString stringWithFormat:@"%@", date]];
}
myDate returns (null).
i've checked my date string and it returns this, so it is not that which is the problem. I've searched on stackoverflow and this is what i've done. What am i doing wrong?
date log
2014-03-16 09:00:00
2014-03-08 09:00:00
2014-03-09 09:00:00
2014-03-15 10:00:00
2014-03-09 11:00:00
2014-03-08 11:00:00
2014-03-16 11:00:00
2014-03-10 12:00:00
2014-03-15 12:00:00
myDate log
2014-03-16 16:00:00 +0000
2014-03-08 16:00:00 +0000
2014-03-09 16:00:00 +0000
2014-03-15 17:00:00 +0000
2014-03-09 18:00:00 +0000
2014-03-08 18:00:00 +0000
2014-03-16 18:00:00 +0000
2014-03-10 07:00:00 +0000
2014-03-15 07:00:00 +0000
(null)