Created
June 4, 2013 12:18
-
-
Save jlcampana/5705495 to your computer and use it in GitHub Desktop.
NSDate ISO8601
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface NSDate (ISO8601) | |
+(NSDateFormatter*)ISO8601Formatter; | |
-(NSString*)ISO8601; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSDate+ISO8601.h" | |
@implementation NSDate (ISO8601) | |
-(NSString*)ISO8601 | |
{ | |
NSDateFormatter * formatter = [NSDate ISO8601Formatter]; | |
return [formatter stringFromDate:self]; | |
} | |
+(NSDateFormatter*)ISO8601Formatter | |
{ | |
NSDateFormatter * dateFormatter = [NSDateFormatter new]; | |
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; | |
return dateFormatter; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment