Answer the question
In order to leave comments, you need to log in
How to parse EST date using NSDate?
There is a date in the form of a string Tue, 18 Dec 2007 24:00:00 EST , you need to get nsdate from it.
Tried like this:
NSDate *date = [@"Tue, 18 Dec 2007 24:00:00 EST" dateWithFormat:@"EEE, dd MMMM yyyy HH:mm:ss ZZZ"];
- (NSDate *)dateWithFormat:(NSString *)format
{
NSDateFormatter *formatter = [NSDateFormatter new];
[formatter setDateFormat:format];
[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"EST"]];
return [formatter dateFromString:self];
}
Answer the question
In order to leave comments, you need to log in
1. you need MMM, not MMMM
2. 24:00:00 - there is no such time
NSDateFormatter *formatter = [NSDateFormatter new];
[formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss 'EST'"];
[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"EST"]];
NSLog(@"%@", [formatter dateFromString:@"Tue, 18 Dec 2007 23:00:00 EST"]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question