5
TimeZone'a göre şimdiki zaman nasıl elde edilir?TimeZone'a göre şimdiki zaman nasıl elde edilir?
example-> Asia/Kolkata için mevcut saat.
TimeZone'a göre şimdiki zaman nasıl elde edilir?TimeZone'a göre şimdiki zaman nasıl elde edilir?
example-> Asia/Kolkata için mevcut saat.
..
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setDateFormat:@"dd/MM/yyyy HH:mm"];
//Create the date assuming the given string is in GMT
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
//Create a date string in the local timezone
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:[NSTimeZone localTimeZone].secondsFromGMT];
NSString *localDateString = [dateFormatter stringFromDate:[NSDate date]];
NSLog(@"date = %@", localDateString);
bu deneyin ve belirli zaman dilimi tarihini istiyorsanız o zaman .. kodunun altına
NSDate *myDate = [NSDate date];
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateStyle:NSDateFormatterLongStyle];
[dateFormatter1 setTimeStyle:NSDateFormatterLongStyle];
[dateFormatter1 setDateFormat:@"dd/MM/yyy hh:mm a"];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName: @"Asia/Calcutta"];
[dateFormatter1 setTimeZone:timeZone];
NSString *dateString = [dateFormatter1 stringFromDate: myDate];
NSLog(@"%@", dateString);
@NeerajSonaro kodu güncelledi. Lütfen kontrol et –
3 upvotes mü? Şok ... internet üzerinden çok fazla örnek var ... –
[UTC NSDate'i yerel Saat Dilimi Hedefi C'ye Dönüştür] 'nin olası kopyası (https://stackoverflow.com/questions/1268509/convert-utc-nsdate-to-local -timezone-objektif-c) – clemens