Reputation: 4289
I have a format 2012-11-19T19:35:00.0000000-07:00 how can I acheive this from NSDate?
NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyy-MM-dd'T'HH:mm:ssZ"];
NSDate *today = [NSDate date];
NSString *dateString =[dateFormatter stringFromDate:today];
NSLog(@"Date is: %@",dateString);
I get the NSLog as 2012-11-09T14:22:00+0530 But I want 2012-11-09T19:35:00.0000000-07:00
How can I get this out.Please help me out.
Upvotes: 1
Views: 128
Reputation: 46543
According to your requirement, you can do this one. The result will be as
//Your desired : 2012-11-09T19:35:00.0000000-07:00
//You will get : 2012-11-09T12:30:00.0000000+05:30
[dateFormatter setDateFormat:@"yyy-MM-dd'T'HH:mm:ss.SSSSSSSZZZZZ"];
Upvotes: 1
Reputation: 912
Use
[dateFormatter setDateFormat:@"yyy-MM-dd'T'HH:mm:ss.SSSSSSSZZZZZ"];
More on how to format dates with NSFormater here.
Hope that helps.
Upvotes: 2
Reputation: 7569
NSDate
conforms to Unicode Technical Standard, you'll need to look into Date_Format_Patterns to find out the format you want,
Upvotes: 1