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,030
  • 21
  • 100
  • 124
Laur Stefan
  • 1,553
  • 4
  • 21
  • 49

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,553
  • 4
  • 21
  • 49