开发者

How to obtain current timezone in objective c

开发者 https://www.devze.com 2023-01-17 22:08 出处:网络
I need to get time zone for the current location such as -5 or +3 and so on. I am unable to do so. I am using datecomponents:

I need to get time zone for the current location such as -5 or +3 and so on. I am unable to do so. I am using datecomponents:

// Turn the date into I开发者_StackOverflow中文版ntegers
NSInteger year = [dateComponents year];
NSInteger month = [dateComponents month];
NSInteger day = [dateComponents day];


NSDateFormatter *date_formater=[[NSDateFormatter alloc]init];
[date_formater setDateFormat:@"Z"];
NSString * tz=[date_formater stringFromDate:[NSDate date]];
0

精彩评论

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

关注公众号