开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜