• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

NSString to NSDate conversion problem

 
Ranch Hand
Posts: 136
Android Mac Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to set the locale of the date formatter.
 
Pratik Goswami
Ranch Hand
Posts: 136
Android Mac Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

reply
    Bookmark Topic Watch Topic
  • New Topic