NSDateFormatter doesn't allow 24-hour format

ios, iphone, nsdate, nsdateformatter

Solution

Just switch

kDateDisplayFormat.dateFormat = @"HH:mm a";

to

kDateDisplayFormat.dateFormat = @"hh:mm a";

Problem

I have to display the date in my app, where i need to display that only in the format of `12 - hour format`, i have used this code to display the `date` ``` NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:kDateDisplayFormat]; NSTimeZone *timeZone = [NSTimeZone systemTimeZone]; [dateFormatter setTimeZone:timeZone]; NSString *todaysDate = [NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:[NSDate date]]]; [[self lblPointsDate] setText:todaysDate]; ``` here when i change my iPhone date format to 24-hour it display's in 24-hour format. I need to convert 24-hour to 12-hour format or make it display only in 12-hour format. How can i do this?

Original source

Related problems