0

I have an app that parses a string date using NSDateFormatter in the following way:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd/MM/yyyy HH:mm"];
NSDate *date = [dateFormatter dateFromString:dateString];

if( !date )
    NSLog(@"Cannot parse date: %@", dateString);

This works on all of our test devices but fails on one single client device. The value of dateString is "25/04/2014 17:22"

What could cause this to fail?

JWood
  • 2,804
  • 2
  • 39
  • 64

1 Answers1

2

Is it possible that this single device has 12-hour time format set? If so, this answer might be helpful: NSDateFormatter in 12-hour mode

Community
  • 1
  • 1
Michał Ciuba
  • 7,876
  • 2
  • 33
  • 59
  • Some POSIX locale might be useful then, which isn't affected by user settings. – gnasher729 May 13 '14 at 16:00
  • I'm going to try setting the locale and see if this makes a difference. The time is set to 12-hour on the failing device but the date format should not be affected by this as we explicitly set the format without relying on the system locale. Also, it works perfectly on a simulator set to 12-hour too. Will give it a shot and accept this answer if it works. – JWood May 14 '14 at 08:18