0

How do I get the current time and format it to ISO 8601?

By these I mean the format: YYYY-MM-DDTHH:MM:SSZ where T and Z are not time represented; they are constants.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Laur Stefan
  • 1,519
  • 5
  • 23
  • 50

1 Answers1

0

The way to achieve this is by:

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm'Z'"];
    NSDate *date = [NSDate date];
    NSLog(@"%@",[dateFormatter stringFromDate:date]);
Laur Stefan
  • 1,519
  • 5
  • 23
  • 50