iphone - NSDateFormatter, NSDate, UTC and strange date format -


I have a very weird date format that is coming to me through JSON. Like - "July, 18 2010 02:22:09"

These dates are always UTC. I am parse date with NSDFFORMER, and setting the time zone to UTC ...

  NSDateFormatter * inputFormatter = [[NSDateFormatter alloc] init]; [InputFirmerTimeJohn: [nstimazon timezonewithbaby: @ "UTC"]]; [InputFormatter setLocale: [[[NSLocale alloc] initWithLocaleIdentifier: @ "en_US"] autorelease]]; [InputFormatter setDateFormat: @ "MMMM, DD YYYY HH: mm: SS"]; NSDate * formatterDate = [inputFormatter dateFromString: dtStr];  

However, the date logged from my device's offsetting is showing ...

"2010-07-18 02:22:09 -0600" / P>

What am I doing wrong here?

I think this is not your NSDate's UTC timezone using DOS NSDT description method About:

representing the receiver's string in international format YYYY-MM-DD HH: MM: SS ± HHMM, where ± HHMM represents the time GMT hours and Offset area in minutes (for example, "2001-03-24 10:45:32 +0600").

So, you are not really doing anything wrong NSDT is behaving as expected. What are you trying to eliminate? Do you need a date of wire? Are you comparing the date?


Comments