Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何获取目标c中的当前时区_Objective C_Cocoa - Fatal编程技术网

Objective c 如何获取目标c中的当前时区

Objective c 如何获取目标c中的当前时区,objective-c,cocoa,Objective C,Cocoa,我需要获取当前位置的时区,例如-5或+3等等。我不能这样做。我正在使用datecomponents: // Turn the date into Integers NSInteger year = [dateComponents year]; NSInteger month = [dateComponents month]; NSInteger day = [dateComponents day]; 谢谢你,亚伦!我还发现tzsecs=([[NSTimeZone localTimeZone]s

我需要获取当前位置的时区,例如-5或+3等等。我不能这样做。我正在使用datecomponents:

// Turn the date into Integers
NSInteger year = [dateComponents year];
NSInteger month = [dateComponents month];
NSInteger day = [dateComponents day];

谢谢你,亚伦!我还发现tzsecs=([[NSTimeZone localTimeZone]secondsFromGMT])/3600;可能重复的
NSDateFormatter *date_formater=[[NSDateFormatter alloc]init];
[date_formater setDateFormat:@"Z"];
NSString * tz=[date_formater stringFromDate:[NSDate date]];