24 hour/12 hour clock problem
In my app it takes the time, but i've noticed that in settings on the device if the user has it set to 24 hour clock, it works as expected where HH fro开发者_如何学Pythonm the current date returns, say 14. But if they have it set to 12 hour clock, it returns as 2. Is there a way of getting around this?
Using this code, I always get the 24-hour clock value.
NSCalendar *cal = [NSCalendar currentCalendar];
NSDate* now = [NSDate date];
int hours = [[cal components:NSHourCalendarUnit fromDate:now] hour];
精彩评论