Date format in ios7

I ran into some strange problem. I get various results over time. My code

 formatter=[[NSDateFormatter alloc]init];
  [formatter setDateFormat:@"yyyy/MM/dd hh:mma"];
    NSDate  *currentdate=[formatter dateFromString:[formatter stringFromDate:[NSDate date]]];
    NSLog(@"Current Date %@",currentdate);

My conclusion is in the simulator and another device

Current date 2013-11-13 11:55:00 +0000

But in one specific device (Iphone 5): the output I get is

Current date 2013-11-13 11:57:00 am +0000

Please help me solve this problem. thanks

+4
source share
2 answers

If it displays a different hour, you may need to set the default time zone after setting dateFormat (this only happens after ios7)

[dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];

, - , , , , . ios7 GMT.

:

NSDate , , , :

[dateFormat setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];

iPhone, , , . sniplets IOS7

+4

, iPhone ( → → ).

24 , u 24- .

12- , u 12- .

, iPhone iPhone5 12 Hr

+2

All Articles