Web Development

It is often recommended to have dates formatted to JSON format when communicating with services. A JSON Date format normally looks like this:

2012-04-23T18:25:43.511Z

To Change a NSDate to JSON Date format, you can do the following:

NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"];
NSString *dateString = [dateFormatter stringFromDate:currDate];
NSLog(@"%@",dateString);

The log would show the date in JSON Date format.