I am using this format to get hours
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"hh";
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
NSString *date = [dateFormatter stringFromDate:now];
NSInteger myHour = [date intValue];
The problem is it returns e.g 4Pm
i Want it to return 16
Instead of 4. How can I do that? I tried replacing hh by single h by of no avail.
Here is answer :-
Hope it helps you!
Its for 12 hour time format :-
Its for 24 hour time format:-
Here Your input:
And date converted to the String ..