I need to convert the date to this string format:
"2011-01-12T14: 17: 55.043Z"
to a number, for example 1294841716 (this is the number of seconds [not milliseconds] since January 1, 1970). Is there an easy way to do this parsing?
Update: Here is the code that I still have:
NSString *dateString = @"2011-01-12T14:17:55.043Z"; NSDateFormatter *inFormat = [[NSDateFormatter alloc] init]; [inFormat setDateFormat:@"yyyy-MM-ddTHH:mm:ss.nnnZ"]; NSDate *parsed = [inFormat dateFromString:dateString]; long t = [parsed timeIntervalSinceReferenceDate];
But t returns as 0 every time.
source share