Created
February 20, 2012 12:02
-
-
Save AidenMontgomery/1868934 to your computer and use it in GitHub Desktop.
This file contains 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
- (NSDate*)toISO8601Date{ | |
NSLocale* enUSPOSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]; | |
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; | |
[dateFormatter setLocale:enUSPOSIXLocale]; | |
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; | |
[dateFormatter setTimeZone:timeZone]; | |
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"]; | |
NSDate* createdDate = [dateFormatter dateFromString:self]; | |
return createdDate; | |
} |
This file contains 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
- (NSString*)toUTCDateString{ | |
NSLocale* enUSPOSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]; | |
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |
[dateFormatter setLocale:enUSPOSIXLocale]; | |
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; | |
[dateFormatter setTimeZone:timeZone]; | |
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"]; | |
NSString *dateString = [dateFormatter stringFromDate:self]; | |
[dateFormatter release]; | |
return dateString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment