0

I in my project I am getting a string I am passing the string to the dateFormatter but I am getting nil, in the string instead of IST I may get PDT I may get any other formats,

NSString* currentDateString = @"2012-11-09 12:31:53.0 **IST**";

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.S z"];

NSDate *dateFromString = [dateFormatter dateFromString:currentDateString];
Cœur
  • 37,241
  • 25
  • 195
  • 267
kiri
  • 1,977
  • 5
  • 27
  • 55
  • 1
    Perhaps it's because IST has four different meanings? http://www.worldtimezone.com/wtz-names/wtz-ist.html (This is why abbreviations are such a bad idea when it comes to time zones.) – Jon Skeet Nov 19 '12 at 06:58
  • Thanks Jon, Can you please help me How can i solve this, How can i set the DateFormat – kiri Nov 19 '12 at 07:00
  • I really don't know, to be honest - but you should ask yourself which of those time zones is really meant when you see the abbreviation "IST". – Jon Skeet Nov 19 '12 at 07:07

1 Answers1

0

If you are testing on iOS 6.0+ device/simulator only, test it on below iOS 6.0 device. I think in Ios 6.0+ something is changed related to abbreviations. Abbreviations dictionary in iOS 6.0+ contains different values than in iOS below 6.0.

Rahul Wakade
  • 4,765
  • 2
  • 23
  • 25