NSDateFormatter with 24 hour times

NSDateFormatter follows the Unicode standard for date and time patterns. Use ‘H’ for the hour on a 24-hour clock:

NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *myDate = [df dateFromString:@"2010-03-14 15:00:00"];

Leave a Comment