hugo411
hugo411

Reputation: 346

obj-c : iphone dateformatter in 12-hours clock format

i want in my application to use the 12 hour clock format so the user can write 15:00 for 3:00 pm so i don't need to create a button am and pm. Thanks

Upvotes: 0

Views: 500

Answers (1)

Jens
Jens

Reputation: 6329

Probably you want to use the 24 hour clock format instead of the 12 hour format. So use a NSDateFormatter with H in the format string. Using one of the predefined formats will end up using your systems localization which probably is the 12 hour format.

NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"HH:mm"];

Upvotes: 1

Related Questions