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
4
votes
2 answers

Getting current time when device was shutting down

I am new to programming. As one of my app need updates if the device is shutting down (switched off), hence I need the current time when the device is getting switched off. and I know that, we can get the system boot time (switched on time) with…
Abirami Bala
  • 760
  • 1
  • 10
  • 25
4
votes
6 answers

How can I get the Correct Current Time in iOS?

I know this it the repeated question. I have reviewed many answers but still didn’t get any solution. My question is, How can I get the Time of Device if user have set it manually..? I have implemented one chatting app. But in this app, I have…
Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
4
votes
2 answers

iOS NSDateFormatter needs NSLocale even it's UTC

I have a doubt that I cannot understand why is the way it is and I appeal to the Gods of this site :) I have a date coming like this: "1982-01-01T00:00:00Z" As I'm displaying whatever the server sends (I know, customer requirement, not good…
4
votes
2 answers

Translate Time Zone Names to Time ID:s

I found out that iOS framework doesn’t understand proper time zone names, like "Eastern Standard Time”. If you type: NSLog(@"EST: %@", [NSTimeZone timeZoneWithName:@"Eastern Standard Time"]); … you get: EST: (null) Instead, you have to use time…
turingtested
  • 6,356
  • 7
  • 32
  • 47
4
votes
1 answer

isDaylightSavingTime returns NO although my time zone does observe DST

Checking -[NSTimeZone isDaylightSavingTime] is giving me NO, and I don't know why. On my system I have the correct time displayed, and my time zone is Eastern US -- New York, which observes DST. NSTimeZone *sZone = [NSTimeZone systemTimeZone]; BOOL…
Vishal
  • 279
  • 3
  • 8
  • 18
4
votes
3 answers

Date selected from UIDatePicker is different from the date being saved

This is how I setup my datePicker self.datePicker = [[UIDatePicker alloc] init]; self.datePicker.timeZone = [NSTimeZone localTimeZone]; This is how I save the date that I selected NSDateFormatter *formatter = [[NSDateFormatter alloc]…
iPhoneJavaDev
  • 821
  • 5
  • 33
  • 78
4
votes
2 answers

Getting city and country from NSTimeZone

I'd like to (at least) get the name of the country for a time zone. This is not provided by any of the potential methods: name, localizedName:locale:, description I notice that the built in iPhone clock App has access to this information, as it…
Benjohn Barnes
  • 121
  • 1
  • 5
4
votes
1 answer

Time Zone Support value - objective-c - cocoa-touch

I've been looking for a while now and have done a good amount of research as well as experimenting, but I cannot find a way to retrieve the value stored in a users settings for Time Zone Support on iOS devices. I have looked into NSTimeZone…
Kevin
  • 436
  • 4
  • 12
3
votes
2 answers

NSDate to GMTDate to JSON format

I want to convert my Local date ([NSDate date]) to GMT to create a JSON string (/Date(1324435876019-0000)/). My code works fine when i set my clock to EST time zone when i change my timezone to PST my code still acts as EST. Can you please tell me…
AAV
  • 3,785
  • 8
  • 32
  • 59
3
votes
1 answer

System timezone vs selected timezone

What's the best way to compare two time zones? I'm facing an issue while comparing two NSTimeZone instances using - (BOOL)isEqualToTimeZone:(NSTimeZone *)aTimeZone method. NSString *timeZoneName = ... NSTimeZone *sytemTimeZone = [NSTimeZone…
Mustafa
  • 20,504
  • 42
  • 146
  • 209
3
votes
2 answers

In iOS is daylight saving in NSTimeZone broken?

I have two variables: NSTimeZone *timeZoneMinus5 = [NSTimeZone timeZoneForSecondsFromGMT: -18000]; NSTimeZone *timeZoneEST = [NSTimeZone timeZoneWithName:@"EST"]; Tested on a device and on the simulator as well both return GMT-05:00. As I'm writing…
kadam
  • 1,259
  • 3
  • 14
  • 27
3
votes
1 answer

How to get the extract the Time zone from systemTimeZone(NSTimeZone)

can any one get me the idea in extracting the Time zone from systemTimeZone(NSTimeZone) i have added the sample along with this. NSTimeZone *localTime = [NSTimeZone systemTimeZone]; NSLog(@" - current local timezone is %@",localTime); Im…
siva
  • 1,402
  • 2
  • 14
  • 28
3
votes
2 answers

Getting time in Swift 4

I'm new to programming and trying to start my journey by learning Swift. Currently I'm working on a weather app which I'm developing for learning purposes. I'm using the openweathermap.org API to get the weather and solar data. Right now I'm fully…
Joseph
  • 89
  • 9
3
votes
1 answer

Cannot change the timezone for DateFormatter in Swift 3

I have just migrated my app's code to Swift 3 and I am getting this really annoying issue with the DateFormatter(formerly NSDateFormatter) that I did not get with Swift 2 or earlier. The issue is that I need to convert a string to a Date object and…
cptdanko
  • 812
  • 2
  • 13
  • 22
3
votes
2 answers

Swift json time value to local time zone

I have a json request that can produce two different types of time values. Both ways it is in UTC time but I need to convert it to local time. 2015-12-01T13:05:33+00:00 or 1:05:33 PM My attempt. let dateFormatter =…
MwcsMac
  • 6,810
  • 5
  • 32
  • 52
1 2
3
16 17