【问题标题】: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"];
    

    【讨论】:

      猜你喜欢
      • 2012-01-10
      • 2019-10-01
      • 2015-07-20
      • 1970-01-01
      • 2019-12-22
      • 1970-01-01
      • 2012-12-23
      • 1970-01-01
      • 2015-08-16
      相关资源
      最近更新 更多