Question

When I run this code on iPhone simulator result is 1 (sundey 30. dec, 2012) but when run on iPhone result is 7. Why?

 NSCalendar *gregorijan = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

 NSDateFormater * dateFormat = [[NSDateFormatter alloc] init];
 NSDate *newDate = [NSDate date];

......

 [dateFormater setDateFormat:[NSString localizedStringWithFormat:@"e"]];

 NSLog (@"%d",[[dateFormater stringFromDate:self.newDate] integerValue]);

 return [[dateFormater stringFromDate:self.newDate] integerValue]; 

I have different values on iPhone and simulator ...

Was it helpful?

Solution

Do not set a date format, instead set the date and time style. To short, medium or long. This uses the device locale settings for formatting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top