-4

The input date string I need to parse is 2013:05:14 13:24:44 I try with this NSDateFormatter code but it does not work... Any idea ?

_dateFormatter = [NSDateFormatter alloc];
[_dateFormatter setDateFormat:@"yyyy:MM:dd hh:mm:ss"];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[_dateFormatter setLocale:usLocale];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
fvisticot
  • 7,936
  • 14
  • 49
  • 79

1 Answers1

2

Instead of hh:mm:ss in the string, you need HH:mm:ss. Since the string shows "13" for the hour, you need to use HH (00-23) instead of hh (01-12).

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
  • 1
    Actually, he needs to read the spec for NSDateFormatter and follow the links to the info on format strings. – Hot Licks May 15 '13 at 15:11
  • I have tried your recommandation (HH:mm:ss) but it does not work as well.. I think the issue is more on the date section (yyyy:MM:dd) – fvisticot May 15 '13 at 15:21