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:


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];

The log would show the date in JSON Date format.