如何根据国家/地区将印度时间转换为其他时间?

时间:2016-07-19 08:57:36

标签: ios objective-c date nstimezone

当用户打开应用程序时,我从服务器获得印度时间。  但如果用户从其他国家/地区打开我的应用,我必须根据该国家/地区显示时间。 怎么解决这个问题?

5 个答案:

答案 0 :(得分:4)

嗨请检查代码:

  NSDate *myDate = [NSDate date];
    NSDateFormatter *f = [[NSDateFormatter alloc] init];
    [f setDateStyle:NSDateFormatterLongStyle];
    [f setTimeStyle:NSDateFormatterLongStyle];
    [f setDateFormat:@"dd MMM YYY HH:mm"];

    NSArray *timeZoneNames = [NSTimeZone knownTimeZoneNames];
    for (NSString *name1 in timeZoneNames)
    {
        NSTimeZone *tz = [NSTimeZone timeZoneWithName:name1];
        [f setTimeZone:tz];

        NSLog(@"%@ = \"%@\" = %@", [tz abbreviation], name1, [f stringFromDate:myDate]);
    }

输出将显示:

2016-07-19 14:46:18.256 da[3702:334577] GMT = "Africa/Abidjan" = 19 Jul 2016 09:16
2016-07-19 14:46:18.257 da[3702:334577] GMT = "Africa/Accra" = 19 Jul 2016 09:16
2016-07-19 14:46:18.257 da[3702:334577] GMT+3 = "Africa/Addis_Ababa" = 19 Jul 2016 12:16
2016-07-19 14:46:18.258 da[3702:334577] GMT+1 = "Africa/Algiers" = 19 Jul 2016 10:16
2016-07-19 14:46:18.258 da[3702:334577] GMT+3 = "Africa/Asmara" = 19 Jul 2016 12:16
2016-07-19 14:46:18.259 da[3702:334577] GMT = "Africa/Bamako" = 19 Jul 2016 09:16
2016-07-19 14:46:18.259 da[3702:334577] GMT+1 = "Africa/Bangui" = 19 Jul 2016 10:16
2016-07-19 14:46:18.260 da[3702:334577] GMT = "Africa/Banjul" = 19 Jul 2016 09:16
2016-07-19 14:46:18.260 da[3702:334577] GMT = "Africa/Bissau" = 19 Jul 2016 09:16
2016-07-19 14:46:18.260 da[3702:334577] GMT+2 = "Africa/Blantyre" = 19 Jul 2016 11:16
2016-07-19 14:46:18.261 da[3702:334577] GMT+1 = "Africa/Brazzaville" = 19 Jul 2016 10:16
2016-07-19 14:46:18.261 da[3702:334577] GMT+2 = "Africa/Bujumbura" = 19 Jul 2016 11:16
2016-07-19 14:46:18.262 da[3702:334577] GMT+2 = "Africa/Cairo" = 19 Jul 2016 11:16
2016-07-19 14:46:18.262 da[3702:334577] GMT+1 = "Africa/Casablanca" = 19 Jul 2016 10:16
2016-07-19 14:46:18.272 da[3702:334577] GMT+2 = "Africa/Ceuta" = 19 Jul 2016 11:16
2016-07-19 14:46:18.272 da[3702:334577] GMT = "Africa/Conakry" = 19 Jul 2016 09:16
2016-07-19 14:46:18.273 da[3702:334577] GMT = "Africa/Dakar" = 19 Jul 2016 09:16
2016-07-19 14:46:18.273 da[3702:334577] GMT+3 = "Africa/Dar_es_Salaam" = 19 Jul 2016 12:16
2016-07-19 14:46:18.274 da[3702:334577] GMT+3 = "Africa/Djibouti" = 19 Jul 2016 12:16
2016-07-19 14:46:18.274 da[3702:334577] GMT+1 = "Africa/Douala" = 19 Jul 2016 10:16
2016-07-19 14:46:18.275 da[3702:334577] GMT+1 = "Africa/El_Aaiun" = 19 Jul 2016 10:16
2016-07-19 14:46:18.275 da[3702:334577] GMT = "Africa/Freetown" = 19 Jul 2016 09:16
2016-07-19 14:46:18.275 da[3702:334577] GMT+2 = "Africa/Gaborone" = 19 Jul 2016 11:16
2016-07-19 14:46:18.276 da[3702:334577] GMT+2 = "Africa/Harare" = 19 Jul 2016 11:16
2016-07-19 14:46:18.276 da[3702:334577] GMT+2 = "Africa/Johannesburg" = 19 Jul 2016 11:16
2016-07-19 14:46:18.277 da[3702:334577] GMT+3 = "Africa/Juba" = 19 Jul 2016 12:16
2016-07-19 14:46:18.277 da[3702:334577] GMT+3 = "Africa/Kampala" = 19 Jul 2016 12:16
2016-07-19 14:46:18.277 da[3702:334577] GMT+3 = "Africa/Khartoum" = 19 Jul 2016 12:16
2016-07-19 14:46:18.278 da[3702:334577] GMT+2 = "Africa/Kigali" = 19 Jul 2016 11:16
2016-07-19 14:46:18.278 da[3702:334577] GMT+1 = "Africa/Kinshasa" = 19 Jul 2016 10:16
2016-07-19 14:46:18.279 da[3702:334577] GMT+1 = "Africa/Lagos" = 19 Jul 2016 10:16
2016-07-19 14:46:18.279 da[3702:334577] GMT+1 = "Africa/Libreville" = 19 Jul 2016 10:16
2016-07-19 14:46:18.280 da[3702:334577] GMT = "Africa/Lome" = 19 Jul 2016 09:16
2016-07-19 14:46:18.280 da[3702:334577] GMT+1 = "Africa/Luanda" = 19 Jul 2016 10:16
2016-07-19 14:46:18.280 da[3702:334577] GMT+2 = "Africa/Lubumbashi" = 19 Jul 2016 11:16
2016-07-19 14:46:18.281 da[3702:334577] GMT+2 = "Africa/Lusaka" = 19 Jul 2016 11:16
2016-07-19 14:46:18.281 da[3702:334577] GMT+1 = "Africa/Malabo" = 19 Jul 2016 10:16
2016-07-19 14:46:18.282 da[3702:334577] GMT+2 = "Africa/Maputo" = 19 Jul 2016 11:16
2016-07-19 14:46:18.282 da[3702:334577] GMT+2 = "Africa/Maseru" = 19 Jul 2016 11:16
2016-07-19 14:46:18.282 da[3702:334577] GMT+2 = "Africa/Mbabane" = 19 Jul 2016 11:16
2016-07-19 14:46:18.283 da[3702:334577] GMT+3 = "Africa/Mogadishu" = 19 Jul 2016 12:16
2016-07-19 14:46:18.283 da[3702:334577] GMT = "Africa/Monrovia" = 19 Jul 2016 09:16
2016-07-19 14:46:18.284 da[3702:334577] GMT+3 = "Africa/Nairobi" = 19 Jul 2016 12:16
2016-07-19 14:46:18.284 da[3702:334577] GMT+1 = "Africa/Ndjamena" = 19 Jul 2016 10:16
2016-07-19 14:46:18.285 da[3702:334577] GMT+1 = "Africa/Niamey" = 19 Jul 2016 10:16
2016-07-19 14:46:18.286 da[3702:334577] GMT = "Africa/Nouakchott" = 19 Jul 2016 09:16
2016-07-19 14:46:18.286 da[3702:334577] GMT = "Africa/Ouagadougou" = 19 Jul 2016 09:16
2016-07-19 14:46:18.287 da[3702:334577] GMT+1 = "Africa/Porto-Novo" = 19 Jul 2016 10:16
2016-07-19 14:46:18.287 da[3702:334577] GMT = "Africa/Sao_Tome" = 19 Jul 2016 09:16
2016-07-19 14:46:18.288 da[3702:334577] GMT+2 = "Africa/Tripoli" = 19 Jul 2016 11:16
2016-07-19 14:46:18.288 da[3702:334577] GMT+1 = "Africa/Tunis" = 19 Jul 2016 10:16
2016-07-19 14:46:18.289 da[3702:334577] GMT+1 = "Africa/Windhoek" = 19 Jul 2016 10:16
2016-07-19 14:46:18.289 da[3702:334577] HADT = "America/Adak" = 19 Jul 2016 00:16
2016-07-19 14:46:18.290 da[3702:334577] AKDT = "America/Anchorage" = 19 Jul 2016 01:16
2016-07-19 14:46:18.290 da[3702:334577] AST = "America/Anguilla" = 19 Jul 2016 05:16
2016-07-19 14:46:18.291 da[3702:334577] AST = "America/Antigua" = 19 Jul 2016 05:16
2016-07-19 14:46:18.291 da[3702:334577] GMT-3 = "America/Araguaina" = 19 Jul 2016 06:16
2016-07-19 14:46:18.292 da[3702:334577] GMT-3 = "America/Argentina/Buenos_Aires" = 19 Jul 2016 06:16
2016-07-19 14:46:18.292 da[3702:334577] GMT-3 = "America/Argentina/Catamarca" = 19 Jul 2016 06:16
2016-07-19 14:46:18.292 da[3702:334577] GMT-3 = "America/Argentina/Cordoba" = 19 Jul 2016 06:16
2016-07-19 14:46:18.293 da[3702:334577] GMT-3 = "America/Argentina/Jujuy" = 19 Jul 2016 06:16
2016-07-19 14:46:18.293 da[3702:334577] GMT-3 = "America/Argentina/La_Rioja" = 19 Jul 2016 06:16
2016-07-19 14:46:18.294 da[3702:334577] GMT-3 = "America/Argentina/Mendoza" = 19 Jul 2016 06:16
2016-07-19 14:46:18.294 da[3702:334577] GMT-3 = "America/Argentina/Rio_Gallegos" = 19 Jul 2016 06:16
2016-07-19 14:46:18.295 da[3702:334577] GMT-3 = "America/Argentina/Salta" = 19 Jul 2016 06:16
2016-07-19 14:46:18.295 da[3702:334577] GMT-3 = "America/Argentina/San_Juan" = 19 Jul 2016 06:16
2016-07-19 14:46:18.296 da[3702:334577] GMT-3 = "America/Argentina/San_Luis" = 19 Jul 2016 06:16
2016-07-19 14:46:18.296 da[3702:334577] GMT-3 = "America/Argentina/Tucuman" = 19 Jul 2016 06:16
2016-07-19 14:46:18.296 da[3702:334577] GMT-3 = "America/Argentina/Ushuaia" = 19 Jul 2016 06:16
2016-07-19 14:46:18.297 da[3702:334577] AST = "America/Aruba" = 19 Jul 2016 05:16
2016-07-19 14:46:18.297 da[3702:334577] GMT-4 = "America/Asuncion" = 19 Jul 2016 05:16
2016-07-19 14:46:18.298 da[3702:334577] EST = "America/Atikokan" = 19 Jul 2016 04:16
2016-07-19 14:46:18.298 da[3702:334577] GMT-3 = "America/Bahia" = 19 Jul 2016 06:16
2016-07-19 14:46:18.299 da[3702:334577] CDT = "America/Bahia_Banderas" = 19 Jul 2016 04:16
2016-07-19 14:46:18.299 da[3702:334577] AST = "America/Barbados" = 19 Jul 2016 05:16
2016-07-19 14:46:18.300 da[3702:334577] GMT-3 = "America/Belem" = 19 Jul 2016 06:16
2016-07-19 14:46:18.300 da[3702:334577] CST = "America/Belize" = 19 Jul 2016 03:16
2016-07-19 14:46:18.300 da[3702:334577] AST = "America/Blanc-Sablon" = 19 Jul 2016 05:16
2016-07-19 14:46:18.301 da[3702:334577] GMT-4 = "America/Boa_Vista" = 19 Jul 2016 05:16
2016-07-19 14:46:18.301 da[3702:334577] GMT-5 = "America/Bogota" = 19 Jul 2016 04:16
2016-07-19 14:46:18.302 da[3702:334577] MDT = "America/Boise" = 19 Jul 2016 03:16
2016-07-19 14:46:18.302 da[3702:334577] MDT = "America/Cambridge_Bay" = 19 Jul 2016 03:16
2016-07-19 14:46:18.303 da[3702:334577] GMT-4 = "America/Campo_Grande" = 19 Jul 2016 05:16
2016-07-19 14:46:18.303 da[3702:334577] EST = "America/Cancun" = 19 Jul 2016 04:16
2016-07-19 14:46:18.303 da[3702:334577] GMT-4:30 = "America/Caracas" = 19 Jul 2016 04:46
2016-07-19 14:46:18.304 da[3702:334577] GMT-3 = "America/Cayenne" = 19 Jul 2016 06:16
2016-07-19 14:46:18.304 da[3702:334577] EST = "America/Cayman" = 19 Jul 2016 04:16
2016-07-19 14:46:18.305 da[3702:334577] CDT = "America/Chicago" = 19 Jul 2016 04:16
2016-07-19 14:46:18.305 da[3702:334577] GMT-6 = "America/Chihuahua" = 19 Jul 2016 03:16
2016-07-19 14:46:18.306 da[3702:334577] CST = "America/Costa_Rica" = 19 Jul 2016 03:16
2016-07-19 14:46:18.306 da[3702:334577] MST = "America/Creston" = 19 Jul 2016 02:16
2016-07-19 14:46:18.307 da[3702:334577] GMT-4 = "America/Cuiaba" = 19 Jul 2016 05:16
2016-07-19 14:46:18.307 da[3702:334577] AST = "America/Curacao" = 19 Jul 2016 05:16
2016-07-19 14:46:18.308 da[3702:334577] GMT = "America/Danmarkshavn" = 19 Jul 2016 09:16
2016-07-19 14:46:18.308 da[3702:334577] PDT = "America/Dawson" = 19 Jul 2016 02:16
2016-07-19 14:46:18.325 da[3702:334577] MST = "America/Dawson_Creek" = 19 Jul 2016 02:16
2016-07-19 14:46:18.326 da[3702:334577] MDT = "America/Denver" = 19 Jul 2016 03:16
2016-07-19 14:46:18.326 da[3702:334577] EDT = "America/Detroit" = 19 Jul 2016 05:16
2016-07-19 14:46:18.327 da[3702:334577] AST = "America/Dominica" = 19 Jul 2016 05:16
2016-07-19 14:46:18.327 da[3702:334577] MDT = "America/Edmonton" = 19 Jul 2016 03:16
2016-07-19 14:46:18.328 da[3702:334577] GMT-5 = "America/Eirunepe" = 19 Jul 2016 04:16
2016-07-19 14:46:18.328 da[3702:334577] CST = "America/El_Salvador" = 19 Jul 2016 03:16
2016-07-19 14:46:18.328 da[3702:334577] MST = "America/Fort_Nelson" = 19 Jul 2016 02:16
2016-07-19 14:46:18.329 da[3702:334577] GMT-3 = "America/Fortaleza" = 19 Jul 2016 06:16
2016-07-19 14:46:18.329 da[3702:334577] ADT = "America/Glace_Bay" = 19 Jul 2016 06:16
2016-07-19 14:46:18.330 da[3702:334577] GMT-2 = "America/Godthab" = 19 Jul 2016 07:16
2016-07-19 14:46:18.330 da[3702:334577] ADT = "America/Goose_Bay" = 19 Jul 2016 06:16
2016-07-19 14:46:18.357 da[3702:334577] AST = "America/Grand_Turk" = 19 Jul 2016 05:16
2016-07-19 14:46:18.357 da[3702:334577] AST = "America/Grenada" = 19 Jul 2016 05:16
2016-07-19 14:46:18.358 da[3702:334577] AST = "America/Guadeloupe" = 19 Jul 2016 05:16
2016-07-19 14:46:18.358 da[3702:334577] CST = "America/Guatemala" = 19 Jul 2016 03:16
2016-07-19 14:46:18.359 da[3702:334577] GMT-5 = "America/Guayaquil" = 19 Jul 2016 04:16
2016-07-19 14:46:18.359 da[3702:334577] GMT-4 = "America/Guyana" = 19 Jul 2016 05:16
2016-07-19 14:46:18.360 da[3702:334577] ADT = "America/Halifax" = 19 Jul 2016 06:16
2016-07-19 14:46:18.360 da[3702:334577] GMT-4 = "America/Havana" = 19 Jul 2016 05:16
2016-07-19 14:46:18.360 da[3702:334577] GMT-7 = "America/Hermosillo" = 19 Jul 2016 02:16
2016-07-19 14:46:18.361 da[3702:334577] EDT = "America/Indiana/Indianapolis" = 19 Jul 2016 05:16
2016-07-19 14:46:18.361 da[3702:334577] CDT = "America/Indiana/Knox" = 19 Jul 2016 04:16
2016-07-19 14:46:18.362 da[3702:334577] EDT = "America/Indiana/Marengo" = 19 Jul 2016 05:16
2016-07-19 14:46:18.362 da[3702:334577] EDT = "America/Indiana/Petersburg" = 19 Jul 2016 05:16
2016-07-19 14:46:18.362 da[3702:334577] CDT = "America/Indiana/Tell_City" = 19 Jul 2016 04:16
2016-07-19 14:46:18.363 da[3702:334577] EDT = "America/Indiana/Vevay" = 19 Jul 2016 05:16
2016-07-19 14:46:18.363 da[3702:334577] EDT = "America/Indiana/Vincennes" = 19 Jul 2016 05:16
2016-07-19 14:46:18.364 da[3702:334577] EDT = "America/Indiana/Winamac" = 19 Jul 2016 05:16
2016-07-19 14:46:18.364 da[3702:334577] MDT = "America/Inuvik" = 19 Jul 2016 03:16
2016-07-19 14:46:18.375 da[3702:334577] EDT = "America/Iqaluit" = 19 Jul 2016 05:16
2016-07-19 14:46:18.376 da[3702:334577] EST = "America/Jamaica" = 19 Jul 2016 04:16
2016-07-19 14:46:18.376 da[3702:334577] AKDT = "America/Juneau" = 19 Jul 2016 01:16
2016-07-19 14:46:18.377 da[3702:334577] EDT = "America/Kentucky/Louisville" = 19 Jul 2016 05:16
2016-07-19 14:46:18.377 da[3702:334577] EDT = "America/Kentucky/Monticello" = 19 Jul 2016 05:16
2016-07-19 14:46:18.378 da[3702:334577] AST = "America/Kralendijk" = 19 Jul 2016 05:16
2016-07-19 14:46:18.378 da[3702:334577] GMT-4 = "America/La_Paz" = 19 Jul 2016 05:16
2016-07-19 14:46:18.378 da[3702:334577] GMT-5 = "America/Lima" = 19 Jul 2016 04:16
2016-07-19 14:46:18.379 da[3702:334577] PDT = "America/Los_Angeles" = 19 Jul 2016 02:16
2016-07-19 14:46:18.379 da[3702:334577] AST = "America/Lower_Princes" = 19 Jul 2016 05:16
2016-07-19 14:46:18.380 da[3702:334577] GMT-3 = "America/Maceio" = 19 Jul 2016 06:16
2016-07-19 14:46:18.380 da[3702:334577] CST = "America/Managua" = 19 Jul 2016 03:16
2016-07-19 14:46:18.381 da[3702:334577] GMT-4 = "America/Manaus" = 19 Jul 2016 05:16
2016-07-19 14:46:18.381 da[3702:334577] AST = "America/Marigot" = 19 Jul 2016 05:16
2016-07-19 14:46:18.381 da[3702:334577] AST = "America/Martinique" = 19 Jul 2016 05:16
2016-07-19 14:46:18.382 da[3702:334577] CDT = "America/Matamoros" = 19 Jul 2016 04:16
2016-07-19 14:46:18.382 da[3702:334577] GMT-6 = "America/Mazatlan" = 19 Jul 2016 03:16
2016-07-19 14:46:18.383 da[3702:334577] CDT = "America/Menominee" = 19 Jul 2016 04:16
2016-07-19 14:46:18.383 da[3702:334577] CDT = "America/Merida" = 19 Jul 2016 04:16
2016-07-19 14:46:18.384 da[3702:334577] AKDT = "America/Metlakatla" = 19 Jul 2016 01:16
2016-07-19 14:46:18.384 da[3702:334577] CDT = "America/Mexico_City" = 19 Jul 2016 04:16
2016-07-19 14:46:18.384 da[3702:334577] GMT-2 = "America/Miquelon" = 19 Jul 2016 07:16
2016-07-19 14:46:18.385 da[3702:334577] ADT = "America/Moncton" = 19 Jul 2016 06:16
2016-07-19 14:46:18.385 da[3702:334577] CDT = "America/Monterrey" = 19 Jul 2016 04:16
2016-07-19 14:46:18.386 da[3702:334577] GMT-3 = "America/Montevideo" = 19 Jul 2016 06:16
2016-07-19 14:46:18.387 da[3702:334577] GMT-4 = "America/Montreal" = 19 Jul 2016 05:16
2016-07-19 14:46:18.387 da[3702:334577] AST = "America/Montserrat" = 19 Jul 2016 05:16
2016-07-19 14:46:18.387 da[3702:334577] EDT = "America/Nassau" = 19 Jul 2016 05:16
2016-07-19 14:46:18.388 da[3702:334577] EDT = "America/New_York" = 19 Jul 2016 05:16
2016-07-19 14:46:18.388 da[3702:334577] EDT = "America/Nipigon" = 19 Jul 2016 05:16
2016-07-19 14:46:18.389 da[3702:334577] AKDT = "America/Nome" = 19 Jul 2016 01:16
2016-07-19 14:46:18.389 da[3702:334577] GMT-2 = "America/Noronha" = 19 Jul 2016 07:16
2016-07-19 14:46:18.389 da[3702:334577] CDT = "America/North_Dakota/Beulah" = 19 Jul 2016 04:16
2016-07-19 14:46:18.390 da[3702:334577] CDT = "America/North_Dakota/Center" = 19 Jul 2016 04:16
2016-07-19 14:46:18.390 da[3702:334577] CDT = "America/North_Dakota/New_Salem" = 19 Jul 2016 04:16
2016-07-19 14:46:18.391 da[3702:334577] MDT = "America/Ojinaga" = 19 Jul 2016 03:16
2016-07-19 14:46:18.391 da[3702:334577] EST = "America/Panama" = 19 Jul 2016 04:16
2016-07-19 14:46:18.391 da[3702:334577] EDT = "America/Pangnirtung" = 19 Jul 2016 05:16
2016-07-19 14:46:18.392 da[3702:334577] GMT-3 = "America/Paramaribo" = 19 Jul 2016 06:16
2016-07-19 14:46:18.392 da[3702:334577] MST = "America/Phoenix" = 19 Jul 2016 02:16
2016-07-19 14:46:18.393 da[3702:334577] EDT = "America/Port-au-Prince" = 19 Jul 2016 05:16
2016-07-19 14:46:18.393 da[3702:334577] AST = "America/Port_of_Spain" = 19 Jul 2016 05:16
2016-07-19 14:46:18.394 da[3702:334577] GMT-4 = "America/Porto_Velho" = 19 Jul 2016 05:16
2016-07-19 14:46:18.394 da[3702:334577] AST = "America/Puerto_Rico" = 19 Jul 2016 05:16
2016-07-19 14:46:18.394 da[3702:334577] CDT = "America/Rainy_River" = 19 Jul 2016 04:16
2016-07-19 14:46:18.395 da[3702:334577] CDT = "America/Rankin_Inlet" = 19 Jul 2016 04:16
2016-07-19 14:46:18.395 da[3702:334577] GMT-3 = "America/Recife" = 19 Jul 2016 06:16
2016-07-19 14:46:18.395 da[3702:334577] CST = "America/Regina" = 19 Jul 2016 03:16
2016-07-19 14:46:18.396 da[3702:334577] CDT = "America/Resolute" = 19 Jul 2016 04:16
2016-07-19 14:46:18.396 da[3702:334577] GMT-5 = "America/Rio_Branco" = 19 Jul 2016 04:16
2016-07-19 14:46:18.397 da[3702:334577] GMT-7 = "America/Santa_Isabel" = 19 Jul 2016 02:16
2016-07-19 14:46:18.397 da[3702:334577] GMT-3 = "America/Santarem" = 19 Jul 2016 06:16
2016-07-19 14:46:18.398 da[3702:334577] GMT-3 = "America/Santiago" = 19 Jul 2016 06:16
2016-07-19 14:46:18.398 da[3702:334577] AST = "America/Santo_Domingo" = 19 Jul 2016 05:16
2016-07-19 14:46:18.399 da[3702:334577] GMT-3 = "America/Sao_Paulo" = 19 Jul 2016 06:16
2016-07-19 14:46:18.399 da[3702:334577] GMT = "America/Scoresbysund" = 19 Jul 2016 09:16
2016-07-19 14:46:18.399 da[3702:334577] MDT = "America/Shiprock" = 19 Jul 2016 03:16
2016-07-19 14:46:18.400 da[3702:334577] AKDT = "America/Sitka" = 19 Jul 2016 01:16
2016-07-19 14:46:18.400 da[3702:334577] AST = "America/St_Barthelemy" = 19 Jul 2016 05:16
2016-07-19 14:46:18.401 da[3702:334577] GMT-2:30 = "America/St_Johns" = 19 Jul 2016 06:46
2016-07-19 14:46:18.401 da[3702:334577] AST = "America/St_Kitts" = 19 Jul 2016 05:16
2016-07-19 14:46:18.401 da[3702:334577] AST = "America/St_Lucia" = 19 Jul 2016 05:16
2016-07-19 14:46:18.402 da[3702:334577] AST = "America/St_Thomas" = 19 Jul 2016 05:16
2016-07-19 14:46:18.402 da[3702:334577] AST = "America/St_Vincent" = 19 Jul 2016 05:16
2016-07-19 14:46:18.403 da[3702:334577] CST = "America/Swift_Current" = 19 Jul 2016 03:16
2016-07-19 14:46:18.403 da[3702:334577] CST = "America/Tegucigalpa" = 19 Jul 2016 03:16
2016-07-19 14:46:18.403 da[3702:334577] ADT = "America/Thule" = 19 Jul 2016 06:16
2016-07-19 14:46:18.404 da[3702:334577] EDT = "America/Thunder_Bay" = 19 Jul 2016 05:16
2016-07-19 14:46:18.404 da[3702:334577] PDT = "America/Tijuana" = 19 Jul 2016 02:16
2016-07-19 14:46:18.404 da[3702:334577] EDT = "America/Toronto" = 19 Jul 2016 05:16
2016-07-19 14:46:18.405 da[3702:334577] AST = "America/Tortola" = 19 Jul 2016 05:16
2016-07-19 14:46:18.405 da[3702:334577] PDT = "America/Vancouver" = 19 Jul 2016 02:16
2016-07-19 14:46:18.406 da[3702:334577] PDT = "America/Whitehorse" = 19 Jul 2016 02:16
2016-07-19 14:46:18.406 da[3702:334577] CDT = "America/Winnipeg" = 19 Jul 2016 04:16
2016-07-19 14:46:18.407 da[3702:334577] AKDT = "America/Yakutat" = 19 Jul 2016 01:16
2016-07-19 14:46:18.407 da[3702:334577] MDT = "America/Yellowknife" = 19 Jul 2016 03:16
2016-07-19 14:46:18.407 da[3702:334577] GMT+8 = "Antarctica/Casey" = 19 Jul 2016 17:16
2016-07-19 14:46:18.408 da[3702:334577] GMT+7 = "Antarctica/Davis" = 19 Jul 2016 16:16
2016-07-19 14:46:18.408 da[3702:334577] GMT+10 = "Antarctica/DumontDUrville" = 19 Jul 2016 19:16
2016-07-19 14:46:18.409 da[3702:334577] GMT+11 = "Antarctica/Macquarie" = 19 Jul 2016 20:16
2016-07-19 14:46:18.409 da[3702:334577] GMT+5 = "Antarctica/Mawson" = 19 Jul 2016 14:16
2016-07-19 14:46:18.409 da[3702:334577] GMT+12 = "Antarctica/McMurdo" = 19 Jul 2016 21:16
2016-07-19 14:46:18.410 da[3702:334577] GMT-3 = "Antarctica/Palmer" = 19 Jul 2016 06:16
2016-07-19 14:46:18.410 da[3702:334577] GMT-3 = "Antarctica/Rothera" = 19 Jul 2016 06:16
2016-07-19 14:46:18.411 da[3702:334577] GMT+12 = "Antarctica/South_Pole" = 19 Jul 2016 21:16
2016-07-19 14:46:18.411 da[3702:334577] GMT+3 = "Antarctica/Syowa" = 19 Jul 2016 12:16
2016-07-19 14:46:18.412 da[3702:334577] GMT+2 = "Antarctica/Troll" = 19 Jul 2016 11:16
2016-07-19 14:46:18.418 da[3702:334577] GMT+6 = "Antarctica/Vostok" = 19 Jul 2016 15:16
2016-07-19 14:46:18.418 da[3702:334577] GMT+2 = "Arctic/Longyearbyen" = 19 Jul 2016 11:16
2016-07-19 14:46:18.419 da[3702:334577] GMT+3 = "Asia/Aden" = 19 Jul 2016 12:16
2016-07-19 14:46:18.419 da[3702:334577] GMT+6 = "Asia/Almaty" = 19 Jul 2016 15:16
2016-07-19 14:46:18.420 da[3702:334577] GMT+3 = "Asia/Amman" = 19 Jul 2016 12:16
2016-07-19 14:46:18.420 da[3702:334577] GMT+12 = "Asia/Anadyr" = 19 Jul 2016 21:16
2016-07-19 14:46:18.420 da[3702:334577] GMT+5 = "Asia/Aqtau" = 19 Jul 2016 14:16
2016-07-19 14:46:18.421 da[3702:334577] GMT+5 = "Asia/Aqtobe" = 19 Jul 2016 14:16
2016-07-19 14:46:18.421 da[3702:334577] GMT+5 = "Asia/Ashgabat" = 19 Jul 2016 14:16
2016-07-19 14:46:18.422 da[3702:334577] GMT+3 = "Asia/Baghdad" = 19 Jul 2016 12:16
2016-07-19 14:46:18.422 da[3702:334577] GMT+3 = "Asia/Bahrain" = 19 Jul 2016 12:16
2016-07-19 14:46:18.422 da[3702:334577] GMT+5 = "Asia/Baku" = 19 Jul 2016 14:16
2016-07-19 14:46:18.423 da[3702:334577] GMT+7 = "Asia/Bangkok" = 19 Jul 2016 16:16
2016-07-19 14:46:18.443 da[3702:334577] GMT+3 = "Asia/Beirut" = 19 Jul 2016 12:16
2016-07-19 14:46:18.444 da[3702:334577] GMT+6 = "Asia/Bishkek" = 19 Jul 2016 15:16
2016-07-19 14:46:18.444 da[3702:334577] GMT+8 = "Asia/Brunei" = 19 Jul 2016 17:16
2016-07-19 14:46:18.444 da[3702:334577] GMT+9 = "Asia/Chita" = 19 Jul 2016 18:16
2016-07-19 14:46:18.445 da[3702:334577] GMT+9 = "Asia/Choibalsan" = 19 Jul 2016 18:16
2016-07-19 14:46:18.445 da[3702:334577] GMT+8 = "Asia/Chongqing" = 19 Jul 2016 17:16
2016-07-19 14:46:18.446 da[3702:334577] GMT+5:30 = "Asia/Colombo" = 19 Jul 2016 14:46
2016-07-19 14:46:18.446 da[3702:334577] GMT+3 = "Asia/Damascus" = 19 Jul 2016 12:16
2016-07-19 14:46:18.447 da[3702:334577] GMT+6 = "Asia/Dhaka" = 19 Jul 2016 15:16
2016-07-19 14:46:18.447 da[3702:334577] GMT+9 = "Asia/Dili" = 19 Jul 2016 18:16
2016-07-19 14:46:18.448 da[3702:334577] GMT+4 = "Asia/Dubai" = 19 Jul 2016 13:16
2016-07-19 14:46:18.448 da[3702:334577] GMT+5 = "Asia/Dushanbe" = 19 Jul 2016 14:16
2016-07-19 14:46:18.449 da[3702:334577] GMT+3 = "Asia/Gaza" = 19 Jul 2016 12:16
2016-07-19 14:46:18.449 da[3702:334577] GMT+8 = "Asia/Harbin" = 19 Jul 2016 17:16
2016-07-19 14:46:18.449 da[3702:334577] GMT+3 = "Asia/Hebron" = 19 Jul 2016 12:16
2016-07-19 14:46:18.450 da[3702:334577] GMT+7 = "Asia/Ho_Chi_Minh" = 19 Jul 2016 16:16
2016-07-19 14:46:18.450 da[3702:334577] GMT+8 = "Asia/Hong_Kong" = 19 Jul 2016 17:16
2016-07-19 14:46:18.451 da[3702:334577] GMT+8 = "Asia/Hovd" = 19 Jul 2016 17:16
2016-07-19 14:46:18.451 da[3702:334577] GMT+8 = "Asia/Irkutsk" = 19 Jul 2016 17:16
2016-07-19 14:46:18.452 da[3702:334577] GMT+7 = "Asia/Jakarta" = 19 Jul 2016 16:16
2016-07-19 14:46:18.452 da[3702:334577] GMT+9 = "Asia/Jayapura" = 19 Jul 2016 18:16
2016-07-19 14:46:18.453 da[3702:334577] GMT+3 = "Asia/Jerusalem" = 19 Jul 2016 12:16
2016-07-19 14:46:18.453 da[3702:334577] GMT+4:30 = "Asia/Kabul" = 19 Jul 2016 13:46
2016-07-19 14:46:18.454 da[3702:334577] GMT+12 = "Asia/Kamchatka" = 19 Jul 2016 21:16
2016-07-19 14:46:18.454 da[3702:334577] GMT+5 = "Asia/Karachi" = 19 Jul 2016 14:16
2016-07-19 14:46:18.455 da[3702:334577] GMT+6 = "Asia/Kashgar" = 19 Jul 2016 15:16
2016-07-19 14:46:18.455 da[3702:334577] GMT+5:45 = "Asia/Kathmandu" = 19 Jul 2016 15:01
2016-07-19 14:46:18.456 da[3702:334577] GMT+5:45 = "Asia/Katmandu" = 19 Jul 2016 15:01
2016-07-19 14:46:18.456 da[3702:334577] GMT+9 = "Asia/Khandyga" = 19 Jul 2016 18:16
2016-07-19 14:46:18.457 da[3702:334577] GMT+5:30 = "Asia/Kolkata" = 19 Jul 2016 14:46
2016-07-19 14:46:18.457 da[3702:334577] GMT+7 = "Asia/Krasnoyarsk" = 19 Jul 2016 16:16
2016-07-19 14:46:18.458 da[3702:334577] GMT+8 = "Asia/Kuala_Lumpur" = 19 Jul 2016 17:16
2016-07-19 14:46:18.458 da[3702:334577] GMT+8 = "Asia/Kuching" = 19 Jul 2016 17:16
2016-07-19 14:46:18.458 da[3702:334577] GMT+3 = "Asia/Kuwait" = 19 Jul 2016 12:16
2016-07-19 14:46:18.459 da[3702:334577] GMT+8 = "Asia/Macau" = 19 Jul 2016 17:16
2016-07-19 14:46:18.459 da[3702:334577] GMT+10 = "Asia/Magadan" = 19 Jul 2016 19:16
2016-07-19 14:46:18.460 da[3702:334577] GMT+8 = "Asia/Makassar" = 19 Jul 2016 17:16
2016-07-19 14:46:18.460 da[3702:334577] GMT+8 = "Asia/Manila" = 19 Jul 2016 17:16
2016-07-19 14:46:18.461 da[3702:334577] GMT+4 = "Asia/Muscat" = 19 Jul 2016 13:16
2016-07-19 14:46:18.461 da[3702:334577] GMT+3 = "Asia/Nicosia" = 19 Jul 2016 12:16
2016-07-19 14:46:18.462 da[3702:334577] GMT+7 = "Asia/Novokuznetsk" = 19 Jul 2016 16:16
2016-07-19 14:46:18.462 da[3702:334577] GMT+6 = "Asia/Novosibirsk" = 19 Jul 2016 15:16
2016-07-19 14:46:18.462 da[3702:334577] GMT+6 = "Asia/Omsk" = 19 Jul 2016 15:16
2016-07-19 14:46:18.463 da[3702:334577] GMT+5 = "Asia/Oral" = 19 Jul 2016 14:16
2016-07-19 14:46:18.463 da[3702:334577] GMT+7 = "Asia/Phnom_Penh" = 19 Jul 2016 16:16
2016-07-19 14:46:18.464 da[3702:334577] GMT+7 = "Asia/Pontianak" = 19 Jul 2016 16:16
2016-07-19 14:46:18.464 da[3702:334577] GMT+8:30 = "Asia/Pyongyang" = 19 Jul 2016 17:46
2016-07-19 14:46:18.465 da[3702:334577] GMT+3 = "Asia/Qatar" = 19 Jul 2016 12:16
2016-07-19 14:46:18.465 da[3702:334577] GMT+6 = "Asia/Qyzylorda" = 19 Jul 2016 15:16
2016-07-19 14:46:18.466 da[3702:334577] GMT+6:30 = "Asia/Rangoon" = 19 Jul 2016 15:46
2016-07-19 14:46:18.466 da[3702:334577] GMT+3 = "Asia/Riyadh" = 19 Jul 2016 12:16
2016-07-19 14:46:18.466 da[3702:334577] GMT+10 = "Asia/Sakhalin" = 19 Jul 2016 19:16
2016-07-19 14:46:18.467 da[3702:334577] GMT+5 = "Asia/Samarkand" = 19 Jul 2016 14:16
2016-07-19 14:46:18.467 da[3702:334577] GMT+9 = "Asia/Seoul" = 19 Jul 2016 18:16
2016-07-19 14:46:18.468 da[3702:334577] GMT+8 = "Asia/Shanghai" = 19 Jul 2016 17:16
2016-07-19 14:46:18.468 da[3702:334577] GMT+8 = "Asia/Singapore" = 19 Jul 2016 17:16

答案 1 :(得分:1)

我尝试将INDIAN时间转换为当地时间的其他国家。我得到了解决方案

NSString *strDate = @"19-07-2016";
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
[dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
NSDate *dateStr = [dateFormat dateFromString:strDate];
NSLog(@"The UTC format date is - %@",dateStr);

[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
[dateFormat setTimeZone:[NSTimeZone systemTimeZone]];
NSString *strLocalDate = [dateFormat stringFromDate:dateStr];
NSLog(@"The Local date is - %@",strLocalDate);

打印结果

The UTC format date is - 2016-07-19 00:00:00 +0000
The Local date is - 2016-07-19 05:30:00

Getting Time based on Local Time Zone

Convert to UTC to Local Time

答案 2 :(得分:0)

试试这个......

-(NSString *)getUTCFormateDate:(NSDate *)serverDate
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
    [dateFormatter setTimeZone:timeZone];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *dateString = [dateFormatter stringFromDate:serverDate];
    return dateString;
}
-(NSString *)getLocalDateTimeFromUTC:(NSString *)strDate
{
    NSDateFormatter *dtFormat = [[NSDateFormatter alloc] init];
    [dtFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    [dtFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
    NSDate *aDate = [dtFormat dateFromString:strDate];

    [dtFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    [dtFormat setTimeZone:[NSTimeZone systemTimeZone]];

    return [dtFormat stringFromDate:aDate];
}

答案 3 :(得分:0)

// Gives Date in UTC
NSDate *currentDate = [[NSDate alloc] init];
// Timezone For India
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Asia/Kolkata"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:timeZone];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];
NSString *localDateString = [dateFormatter stringFromDate:currentDate];

答案 4 :(得分:0)

首先,请记住两件事:

  1. IOS中的日期为" 不可变,表示相对于绝对参考日期(2001年1月1日00:00:00 UTC)的不变时间间隔" (ref)。无论设备在地球的哪个位置,其内部表示始终相对于该UTC时间点。

  2. 日期格式器默认为用户的区域设置(ref)。这意味着,只要用户的设备在“设置”中具有正确的时间和时区,您就不需要做任何额外的操作来将时间转换为本地格式和区域。

    < / LI>

    所以,你应该做的是在将值分配给NSDate之前将印度转换为UTC,而IOS将负责其余的工作。