onmyway133 / notes

:notebook_with_decorative_cover: Issues and solutions I found during development, mostly iOS
https://onmyway133.com/
MIT License
63 stars 4 forks source link

NSDateFormatter daylight saving time #260

Open onmyway133 opened 7 years ago

onmyway133 commented 7 years ago
formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss Z";
formatter.timeZone = [NSTimeZone localTimeZone];
onmyway133 commented 7 years ago

This works "2015-08-11 00:59:00 +0100"

formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss Z";

NSTimeInterval offset = [[NSTimeZone systemTimeZone] secondsFromGMT];
formatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:offset];