I am converting a NSDate object to string format. using GHKit
. Internally its using NSDateFormatter
stringFromDate
[NSDate date] gh_format:@"yyyy-MM-dd HH:mm:ss zzz" useWeekday:NO]
- (NSString *)gh_format:(NSString *)format useWeekday:(BOOL)useWeekday {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:format];
NSString *formatted = [dateFormatter stringFromDate:self];
if (useWeekday) {
NSString *specialWeekday = [self gh_weekday:dateFormatter];
formatted = [NSString stringWithFormat:@"%@, %@", specialWeekday, formatted];
}
[dateFormatter release];
return formatted;
}
This method works fine with iOS 5, 6 producing the following output
2013-10-10 10:43:44 GMT+05:00
However iOS 7 produces something like this which my web server is unable to parse
2013-10-10 10:43:44 GMT+5
Try using yyyy-MM-dd HH:mm:ss ZZZZ
for your date format.
See http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns for more info
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.