Remove time zone offset from date in iOS

ios, nsdate, rubymotion

Solution

NSDate.date returns a date with the current date and time stored as GMT.

If you want to format the date as a string and show the GMT time, you should use a NSDateFormatter and set the locale to GMT:

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"GMT"]];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"];

NSString *dateAsString = [formatter stringFromDate:[NSDate date]];

Problem

I need to get the current `NSDate.date` and remove the time zone and parse it as a GMT date ``` NSDate.date ``` returns `2012-10-11 11:27:09 -0700` What I need is this: `2012-10-11 11:27:09 +0000`

Original source