D
D
deleted-mezhevikin2013-11-05 13:24:34
iOS
deleted-mezhevikin, 2013-11-05 13:24:34

Problem with timezones in NSDate?

From different rss I get dates in different time zones, I need to display them in the user's zone [NSTimeZone systemTimeZone].
How to do it right?
Tried like this:

- (NSDate *)convertDate:(NSString *)date
{
    NSString *dateFormat = @"EEE, dd MMMM yyyy HH:mm:ss zzz";
    NSDateFormatter *dateFormatter = ;
    [dateFormatter setDateFormat:dateFormat];
    NSLog(@"%@ --- %@", date, [dateFormatter dateFromString:date]);
    return [dateFormatter dateFromString:date];
}

- (id)init
{
   [self convertDate:@"Sat, 02 Nov 2013 15:58:00 PDT"];
   [self convertDate:@"Fri, 27 Sep 2013 11:26:22 +0400"];
}

Console output (in my case Moscow timezone)
Sat, 02 Nov 2013 15:58:00 PDT --- 2013-11-02 22:58:00 +0000
Fri, 27 Sep 2013 11:26:22 +0400 --- 2013-09-27 07:26:22 +0000

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hybridcattt, 2013-11-05
@deleted-mezhevikin

Everything is working correctly for you.
NSLog always displays the date in the GMT zone.
Please note that in your second case 11:26 +04:00 is the same time as 07:26 +00:00

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question