Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NSString to NSDate conversion problem

 
Pratik Goswami
Ranch Hand
Posts: 136
Android Chrome Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am having a NSString object which I am converting to NSDate with help of NSDateFormatter. Now code works fine here with all the OS but it is creating different Output at client's add (USA region).
Here is the code that I am using.


Output at my end -------2010-09-24 17:30:00 - 0700
Output at Client end ----2010-09-25 00:30:00 GMT

Can anyone please suggest where's the problem?

Thanks
Pratik Goswami
 
Alaa Nassef
Ranch Hand
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to set the locale of the date formatter.
 
Pratik Goswami
Ranch Hand
Posts: 136
Android Chrome Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Alaa,

The problem with the second output - '2010-09-25 00:30:00 GMT' is that if I do some calculation (adding minutes to NSDate) and converting again to NSDate creates problem, it automatically adds 7 hours to date. The problem is being created at client end only. At my end same logic works perfecly and produces exact result as expected.

Any idea?

Thanks
Pratik Goswami
 
Alaa Nassef
Ranch Hand
Posts: 471
Hibernate Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that this is a locale/timezone problem. As I've said before, try to set the locale of the date formatter, and see what happens.
 
christo kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alaa Nassef wrote:I believe that this is a locale/timezone problem. As I've said before, try to set the locale of the date formatter, and see what happens.


Hi Alaa and Pratik,

Even I am facing the same problem, In my case [NSDate description] returning
Output at my end -------2010-09-24 17:30:00 - 0700
Output at Client end ----2010-09-25 00:30:00 GMT

Seems like related to iPhone setting or OS incompatibility thing,
Pratik if you resolved it please share.

Thanks
Christo

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic