5

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

silasjmatson
  • 1,814
  • 18
  • 37

1 Answers1

7

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]];
J. Steen
  • 15,470
  • 15
  • 56
  • 63
lnafziger
  • 25,760
  • 8
  • 60
  • 101