diff --git a/NSDate+Helper.m b/NSDate+Helper.m index 5b84d1d..36213e1 100644 --- a/NSDate+Helper.m +++ b/NSDate+Helper.m @@ -251,6 +251,14 @@ - (NSString *)stringWithFormat:(NSString *)format { return timestamp_str; } +- (NSString *)stringWithFormatISO8601; { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + NSLocale *enUSPOSIXLocale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]; + [dateFormatter setLocale:enUSPOSIXLocale]; + [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"]; + return [dateFormatter stringFromDate:self]; +} + - (NSString *)string { return [self stringWithFormat:[NSDate dbFormatString]]; }