Get bad weather using NSDateFormatter


When i am

[dateFormatter setDateFormat:@"HH:mm"]

using to fetch the current hour i am getting correct time till 12:59 but after that it again starts from 1:00 i.e. 12:59 is displayed as 12:59 but 14:00 is displyed as 2:00.

Please let me if anyone is also having a similar problem and suggest a solution.


Please check the code below.

    NSDateFormatter *dateFormator = [[NSDateFormatter alloc] init];
    dateFormator.dateStyle = NSDateFormatterMediumStyle;
    [email protected]"HH:mm:ss";
    NSCalendar * calender=[[NSCalendar alloc]initWithCalendarIdentifier:[NSGregorianCalendar autorelease]];
    NSDateComponents * component=[calender components:NSHourCalendarUnit|NSMinuteCalendarUnit fromDate:date];