24hr & uiDatePicker

只谈情不闲聊 提交于 2019-12-23 03:04:14

问题


I need the time from my uiDatePicker to be in 24hr format, I understand you can't force this mode if the device is set to display AM/PM? If thats the case, how can I detect the device is in 24hr mode (or not) so I can add 12 to my PM times? Many thanks for any help...


回答1:


Wel you can, you need to set the local:

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"NL"];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
[formatter setTimeZone:timeZone];
[formatter setLocale:locale];
[locale release], locale = nil;


来源:https://stackoverflow.com/questions/6197641/24hr-uidatepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!