开发者

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

开发者 https://www.devze.com 2022-12-28 22:57 出处:网络
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开发者_Go百科 need to create a button am and pm. ThanksProbably you want to use the 24 hour

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开发者_Go百科 need to create a button am and pm. Thanks


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"];
0

精彩评论

暂无评论...
验证码 换一张
取 消