I need to convert this string date "2011-06-25T11:00:26+01:00” into a long like value.
I tried this
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[df setDateFormat:@"yyyy-MM-ddHH:mm:ssZ"];
NSDate *date = [df dateFromString:[time stringByReplacingOccurrencesOfString:@"T" withString:@""]];
[df setDateFormat:@"eee MMM dd, yyyy hh:mm"];
NSLog(@"time%@", time);
long lgTime = (long)[date timeIntervalSince1970];
but this doesn't work. Please help me.
Thanks in advance.
If you want to convert "2011-06-25T11:00:26+01:00” to "2011-06-25T11:00:26GMT+01:00" which can be parsed
Hope this helps you
First of all, I missed this the first time but
"2011-06-25T11:00:26+01:00”
is cannot be parsed. The correct string would be"2011-06-25T11:00:26+0100”
.Once you've the string in that format, use the date format –
"yyyy-MM-dd'T'HH:mm:ssZ"
.Example usage