获得系统所有时区

    技术2025-12-23  4

     

    NSDate *nowDate = [NSDate new];

    NSDateFormatter *formatter =  [[NSDateFormatter allocinit];

    [formatter setDateFormat:@"yyyy/MM/dd HH:mm:ss"];

    //获取所有的时区名字

    NSArray *array = [NSTimeZone knownTimeZoneNames];

    // NSLog(@"array:%@",array);

    //快速枚举法

    for(NSString *timeZoneName in array){

    [formatter setTimeZone:[NSTimeZone timeZoneWithName:timeZoneName]];

    NSLog(@"%@,%@",timeZoneName,[formatter stringFromDate:nowDate]);

    }

    [formatter release];

    [nowDate release];

     

    最新回复(0)