开发者

Using NSDateFormatter to format date to local date

开发者 https://www.devze.com 2023-01-15 23:40 出处:网络
I have tried numer开发者_StackOverflow中文版ous attemps of formatting a relatively simple date format to a date object, but also converting to my local time zone.

I have tried numer开发者_StackOverflow中文版ous attemps of formatting a relatively simple date format to a date object, but also converting to my local time zone.

All dates are formatte like this: 2010-09-11T08:55:00. This is GMT time, and I want it converted to a date object with GMT+2.

Can anyone please point me in the right direction?


I just figured out how to format the date:

NSString *str = @"2010-09-10T18:24:43";

NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
NSDate *date = [format dateFromString:str];

[format setDateFormat:@"EEEE MMMM d, YYYY"];
str = [format stringFromDate:date];
[format release];

NSLog(@"%@", str);

Just need to convert to local timezone now..

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号