I am trying to set the date format for something like "2011-04-21 03:31:37.310396". I think I'm not getting the fractional seconds right. I'm looking at http://unicode.org/reports/tr35/tr35-10.html#Date_Format_Patterns for guidelines on how to specify it and I think my issue is in the format itself.
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ssSSSSSS";
NSDate* serverDate = [dateFormatter dateFromString:stringFormOfDate];
Help?
try
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSSSSS";
NSDate* serverDate = [dateFormatter dateFromString:@"2011-04-21 03:31:37.310396"];
NSLog(@"%@", serverDate);
I guess you probably forgot the dot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With