从UIDatePicker iOS检索日期和时间 [英] Retrieve date and time from UIDatePicker iOS

查看:76
本文介绍了从UIDatePicker iOS检索日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望以2013年5月31日星期五中午12:00的格式检索日期和时间。如何使用NSDateFormatter实现这一目标?

I want to retrieve date and time in format e.g "Friday May 31, 2013 12:00 pm". How can I achieve that with NSDateFormatter?

推荐答案

NSDate *myDate = datePicker.date;

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"cccc, MMM d, hh:mm aa"];
NSString *prettyVersion = [dateFormat stringFromDate:myDate];

这篇关于从UIDatePicker iOS检索日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆