【问题标题】:question related to conversion from NSDate to NSString有关从 NSDate 转换为 NSString 的问题
【发布时间】:2009-12-16 10:26:08
【问题描述】:

NSString *abc = @"2009-12-12 16:25:00";

我有 1 个这种格式的字符串,如上所示。

NSDate *currentDate = [NSDate 日期]; 现在我希望 currentDate 也采用 2009-12-12 16:25:00 指定的这种格式

我还想用指定的 thisformat 2009-12-12 16:25:00 将此 currentDate 从 NSdate 转换为 NSString 格式

帮帮我

【问题讨论】:

    标签: iphone


    【解决方案1】:
        NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
        [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSString* golly = [dateFormatter stringFromDate:[NSDate date]];
    

    【讨论】:

      【解决方案2】:

      使用NSDateFormatter。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-10
        • 1970-01-01
        • 1970-01-01
        • 2011-11-25
        • 1970-01-01
        • 1970-01-01
        • 2023-03-25
        相关资源
        最近更新 更多