Questions tagged [nstimezone]

Time Zone data for iOS and Mac OS X

NSTimeZone is a class that presents IANA time zone data as an Objective-C () class. It's part of the Foundation framework () on Mac OS X () and iOS () and in Cocotron and GNUStep.

255 questions
1
vote
1 answer

UILocalNotification & NSTimeZone, wrong timezone showing up

I am trying here to set an alarm. I am located in Montréal, so in the EST Timezone. In the code I am using, I get the current date, and try to make it ring some minutes later. The code works perfectly fine, and the alarm rings as expected. Here is…
1
vote
2 answers

NSTimeZone difference to GMT

I need to get the information of the difference between users timezone, to GMT London time, in hours, or minutes. Anyone can help? I've been looking around and i'm kind of confused. Thanks, rui
Rui Lopes
  • 2,562
  • 6
  • 34
  • 49
1
vote
2 answers

How to set the time zone for a date in iOS 3.x

Anyone know how to set the time zone in an NSDate object prior to iOS 4.0? In iOS 4 and greater I do the following: NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease]; NSDateComponents…
user1060816
  • 75
  • 2
  • 6
1
vote
2 answers

Wrong time with NSDate and NSTimezone

I have two dates (written in two different NSString), for example 31/12/2011 and 31/03/2012 I have to check if today is in this range. For read the date from the NSString, I'm doing this: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]…
JAA
  • 1,024
  • 3
  • 20
  • 34
1
vote
3 answers

iPhone4 iOS5 [[NSTimeZone localTimeZone] daylightSavingTimeOffset] wrong for daylight savings time?

I live in the US eastern time zone (EST), and a couple weeks ago the daylight savings began. I was testing some of my earlier code, which was working(supposedly) fine and noticed that the day second calculations are running 1 hour earlier. here's…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
1
vote
1 answer

The purpose behind TimeZone vs NSTimeZone

Why there is a TimeZone with an API significantly different than NSTimeZone? Say NSTimeZone has init(name: String) and TimeZone does not. NSTimeZone has abbreviation property and in TimeZone abbreviation is a function that takes Date as a parameter…
Anton Tropashko
  • 5,486
  • 5
  • 41
  • 66
1
vote
1 answer

Swift - How do I get an NSTimeZone to give me "Pacific Standard Time" or "Mountain Time" etc?

The API I am using gives me names like "America/Vancouver". I use this to construct an NSTimeZone and get the the abbreviation, but it's "UTC-7" when I want "Pacific Daylight Time" or "PDT". How can I get into the zone? And not the danger zone.
Tom Schulz
  • 612
  • 6
  • 23
1
vote
1 answer

iOS API TimeZone.current does not return actual system time

My iOS swift application calls TimeZone.current when the application comes to the foreground. If I manually change the timezone from Settings->General->Date&Time, and then bring my application to the foreground, I get the correct timezone. But if my…
rlr
  • 320
  • 2
  • 11
1
vote
2 answers

Not Getting Proper Time Zone

I am very new in iPhone. I have one issue. First Just check my code. NSString *timeZone=[NSString stringWithFormat:@"%@",[[NSTimeZone systemTimeZone] abbreviation]]; NSLog(@"Print Time Zone :- '%@'",timeZone); NSRange Timerange=[timeZone…
SJS
  • 2,647
  • 1
  • 17
  • 34
1
vote
1 answer

iOS TimeZone get three letter abbreviation

I need to get three/four letter abbreviation for the country called 'Africa/Nairobi', I have tried using print(TimeZone(abbreviation: "SAST")?.identifier) from the NSTimeZone.abbreviationDictionary, results nil. How to get the three/four letter…
1
vote
1 answer

Does NSTimeZone in iPhone adjust automatically for DST

I have a fairly simple question. I have a set of dates in UTC. I want to represent these to the user in the correct local time adjusted (or not, if DST is not currently in effect) for DST. So, if I do something such as the following, will timeStamp…
1
vote
2 answers

Date (String) to Date (ISO) at Swift

I am aware about similar questions, however, I couldn't find this exact one: In an iOS application, I am receiving a date in the format dd-MM-yyyy HH:mm:ss (i.e. 30-07-2019 12:05:00) in GMT +2h, and I like to convert it to yyyy-MM-dd HH:mm:ss +0000…
j___.___j
  • 286
  • 1
  • 3
  • 20
1
vote
3 answers

NSDateFormatter behavior problem

I have a problem using NSDateFormatter in iPhone programming. Below is my code snippet. NSString *inputDate = @"2011-03-14"; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy-MM-dd"]; NSDate *entryDate =…
Jan
  • 11
  • 1
1
vote
1 answer

How to convert time between timezones taking daylightsavings into account?

I have the following function for converting time: static func convert(date: String) -> String { let formatter = DateFormatter() formatter.dateFormat = "h:m:s a" formatter.timeZone = TimeZone(identifier: "UTC") let…
1
vote
1 answer

Issue in formatting date string Swift 3

I need to convert the following date string in to a Date in Swift 3. Fri Dec 09 16:18:43 AMST 2016 Here is the code that i have been using, but it's getting cash on this particular date string conversion. (This date was logged on Android using…
Chrishan
  • 4,076
  • 7
  • 48
  • 67