【发布时间】:2011-06-01 07:25:08
【问题描述】:
我需要将 uiDatePicker 中的时间设置为 24 小时格式,我知道如果设备设置为显示上午/下午,您不能强制使用此模式? 如果是这样,我怎样才能检测到设备处于 24 小时模式(或不是),以便我可以在我的 PM 时间中添加 12? 非常感谢您的帮助...
【问题讨论】:
标签: iphone nsdate uidatepicker
我需要将 uiDatePicker 中的时间设置为 24 小时格式,我知道如果设备设置为显示上午/下午,您不能强制使用此模式? 如果是这样,我怎样才能检测到设备处于 24 小时模式(或不是),以便我可以在我的 PM 时间中添加 12? 非常感谢您的帮助...
【问题讨论】:
标签: iphone nsdate uidatepicker
你可以,你需要设置本地:
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;
【讨论】: