UIDatePicker 和 NSDate
我有一个从 UIDatepicker 获得的 NSDate。
IBOutlet UIDatePicker *dueDate;
NSDate *selectedDate = [dueDate date];
如何以 int
的形式从 dueDate
检索月份? (1 月为 1 月,2 月为 2 月,依此类推)
I have an NSDate that I get from a UIDatepicker.
IBOutlet UIDatePicker *dueDate;
NSDate *selectedDate = [dueDate date];
How do I retrieve the month from dueDate
in the form of an int
? (1 for Jan, 2 for Feb, etc.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
-[NSCalendar Components:fromDate:]
例如这里的示例:http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html
use
-[NSCalendar components:fromDate:]
for instance the example here:http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html