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
153
votes
7 answers

How to get a user's time zone?

Does anyone know of a way to get a users time zone in Swift? I'm getting a specific time something is on t.v. out of a database and then need to subtract/add from where they are located to show them the correct time it's on.
Keith
  • 1,969
  • 4
  • 17
  • 27
51
votes
1 answer

Where can I find a list of timezones?

I use timeZoneWithName, but I don't know names of timezones. Where can I find a list of timezones? [NSTimeZone timeZoneWithName:@"US/Eastern"];
Voloda2
  • 12,359
  • 18
  • 80
  • 130
51
votes
1 answer

iPhone - Differences among time zone convenience methods

I see that NSTimeZone has these methods : defaultTimeZone localTimeZone systemTimeZone Can someone explain to me, in simple terms, what the differences are beetween those calls, and when one should be used instead of the other? I don't…
Oliver
  • 23,072
  • 33
  • 138
  • 230
41
votes
6 answers

Detect if time format is in 12hr or 24hr format

Is there any way to detect if the current device of the app uses 12h our 24h format, so that I can use one NSDateFormatter for 12h and one for 24h depending on the users language/loaction setting? Just Like the UIDatePicker detects and shows the…
JonasG
  • 9,274
  • 12
  • 59
  • 88
38
votes
3 answers

NSTimeZone: Any difference between "UTC" and "GMT"?

Are these five statements interchangeable, or is anyone aware of cases where their use would yield different results? From what I gather they are equivalent but I haven't found anything conclusive, and potential differences between the GMT and the…
Clafou
  • 15,250
  • 7
  • 58
  • 89
25
votes
2 answers

iOS - How to get raw offset for timezone?

How do I get the raw offset in milliseconds for Coordinated Universal Time in iOS programmatically?
Suchi
  • 9,989
  • 23
  • 68
  • 112
20
votes
2 answers

Convert NSDate to NSString with NSDateFormatter with TimeZone without GMT Time Modifier

I'm initializing my NSDateFormatter thusly: NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]]; [dateFormatter…
Heath Borders
  • 30,998
  • 16
  • 147
  • 256
19
votes
6 answers

How to use NSTimeZone -timeZoneWithName: with a city name from Rails ActiveSupport?

If I only have the city name like Bangkok or Tokyo, how can I supply a timezone parameter in [NSTimeZone timeZoneWithName:@"Asia/Tokyo"] where it also has continent and slash in front of city? I already tried [NSTimeZone timeZoneWithName:@"Tokyo"],…
Hlung
  • 13,850
  • 6
  • 71
  • 90
17
votes
2 answers

Type 'TimeZone' has no member 'local' in Swift3

I am converting project developed in Swift2.3 to Swift3.0 using Xcode8 Beta4. In which I have method to convert date to string, but it fails to convert it. class func convertDateToString(_ date:Date, dateFormat:String) -> String? { let…
technerd
  • 14,144
  • 10
  • 61
  • 92
16
votes
3 answers

Swift 3 timezone issue

It seems setDefaultTimeZone method is no longer available in NSTimeZone. Does someone know a substitute for this? In my AppDelegate.swift, I have: NSTimeZone.default = TimeZone(abbreviation: "BST")! and it works as intended I guess because in all…
AmrataB
  • 1,066
  • 2
  • 10
  • 19
16
votes
2 answers

How to change string to date without converting to any timezone in Swift?

I know there are lot of questions passing around over this simple issue, but still I couldn't get a clear idea. Here is what I want: SelectedDateString = "19-08-2015 09:00 AM" let dateFormatter = NSDateFormatter() dateFormatter.dateFormat =…
AAA
  • 1,957
  • 4
  • 23
  • 42
11
votes
1 answer

Time Zone offset number in Objective-c?

How can I get the Timezone offset in Objective-C (for iPhone OS 3)? For example, GMT -5 is US Eastern Time. I want the -5 part of it. How would I do so?
Moshe
  • 57,511
  • 78
  • 272
  • 425
10
votes
5 answers

How to identify timezone from longitude and latitude in iOS

How can I find out which NSTimeZone a given longitude and latitude fall in?
suse
  • 10,503
  • 23
  • 79
  • 113
10
votes
4 answers

iOS create date in the future ignoring daylight savings

I'm trying to work with dates and create dates in the future, but daylight savings keeps getting in the way and messing up my times. Here is my code to move to midnight of the first day of the next month for a date: + (NSDate…
Josh
  • 3,445
  • 5
  • 37
  • 55
9
votes
3 answers

How to get full time zone name ios

How do we get full time zone name in iOS like Indian Standard Time instead of IST. NSTimezone *timeZone=[NSTimeZone localTimeZone]; i am getting GMT but i want it like full form string
PAn Kaj Khatri
  • 539
  • 1
  • 6
  • 22
1
2 3
16 17