I know how to use NSTimeZone to get the offset for the current time in another time zone. NSDate always returns relative to GMT, so how can I get a string with time zone information? those. I take the current time where I am (in EST), and using NSTimeZone, I subtract 3 hours needed to represent the time in PST. But all I did is subtract 3 hours from the time that is still presented relative to my time zone. How to get NSDateFormatter to spit out time using destination time zone?
One trick I tried was:
NSCalendar *cal = [NSCalendar currentCalendar]; NSDate *now = [NSDate date]; NSTimeZone *tz = [NSTimeZone timeZoneForSecondsFromGMT:(-8 * 3600)];
No love. I could take individual date components and compose a string, but that would not be localizable.
Related problem:
NSTimeZone *tz = [NSTimeZone timeZoneForSecondsFromGMT:(-8 * 3600)];
Both abbreviation and name return GMT-0800 , not PST, as I expected. Therefore, I could not even do higher if I wanted to. What am I doing wrong?
date timezone formatting iphone nsdate
rsswtmr Mar 23 '10 at 20:34 2010-03-23 20:34
source share