Mike
Mike

Reputation: 3084

How to I get UTC from NSDateFormatter?

The following code in iOS

NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateStyle:NSDateFormatterFullStyle];
[formatter setTimeStyle:NSDateFormatterLongStyle];
[formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation: @"UTC"]];
NSString *dateString = [formatter stringFromDate: date];

returns a date string like

Monday, May 6, 2013, 10:42:10 PM GMT

Unfortunately, UTC is not exactly the same at GMT--it's off by one hour when the UK is on daylight savings time. How to I convince NSDateFormatter to actually return UTC rather than GMT?

Upvotes: 1

Views: 155

Answers (1)

Adam Shiemke
Adam Shiemke

Reputation: 3742

According to this post, the two are implemented the same in code. I don't believe you need to worry about it.

Upvotes: 1

Related Questions