【问题标题】:How to get particular time with my current date? [duplicate]如何获取当前日期的特定时间? [复制]
【发布时间】:2013-01-24 06:59:05
【问题描述】:
可能重复:
How do i add 1 day to a NSDate?
我不想在NSDate 中添加时间(上午 10 点)
在string 我得到这样的数据:
10:00 AM
我想用当前日期将这次string 转换为NSDate。
在NSDate 中,我不需要像2013-01-24 10:00:00 +0000 这样的数据
我想要NSDate 中的这些数据。
请建议我该怎么做?
【问题讨论】:
标签:
iphone
ios
objective-c
nsdate
nsdateformatter
【解决方案1】:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"hh:mm a"];
NSDate *date = [dateFormatter dateFromString:@"10:00 AM"];