harishkashyap
harishkashyap

Reputation: 114

How to obtain current timezone in objective c

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 Integers
NSInteger year = [dateComponents year];
NSInteger month = [dateComponents month];
NSInteger day = [dateComponents day];

Upvotes: 3

Views: 5561

Answers (1)

Aaron Saunders
Aaron Saunders

Reputation: 33345

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

Upvotes: 6

Related Questions