Hey, guys i searched a lot but cant get my code working.
I am getting a date in form of a string with format like : 2011-04-18 18:57:47.453000
I want to convert this to NSDate to calculate time elapsed, but I cant seem to get the conversion right. here is what i am doing:
NSString *dateString = [entityData objectForKey:@"creation_time"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.fff"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:dateString];
[dateFormatter release];
when i print dateString i get : 2011-04-18 18:57:47.453000
but printing dateFromString gives: (null)
Can anyone point me in the right direction?
You probably solved this awhile ago… but:
Some good information on converting date components can be found in the “Date Field Symbol Table” located here:
http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns