I'm new to iOS and I'm trying to understand how to use dates and formatters to create a date object that represents the current time, but in the UTC time zone. That is, if my local time on my device is 3pm PST, I want to create a date object that represents the time 3pm UTC. I do NOT want to convert 3pm PST to the UTC equivalent, but instead create the 3pm UTC date using the 3pm PST local time date. My current code is...
NSTimeZone *utcTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];
[dateFormatter setTimeZone:utcTimeZone];
NSString *nowInUTCString = [dateFormatter stringFromDate:[NSDate date]];
...but this essentially converts my local time to UTC time, which is what I do NOT want. I'm still reading up on the docs, but I thought I'd post this in the meantime. Any help?
Thanks so much in advance for your wisdom!