代码之家  ›  专栏  ›  技术社区  ›  Douglas Mayle

如何用nsdateformator解释日期?

  •  1
  • Douglas Mayle  · 技术社区  · 15 年前

    在Apple文档中,他们说nsdateFormatter使用Unicode作为规范。我已经阅读了规范,但在解释这个日期时遇到了问题:

    NSDateFormatter *frm = [[NSDateFormatter alloc] init];
    [frm setDateFormat:@"EEE MMM dd HH:mm:ss ZZZ yyyy"];
    NSLog(@"Tue Oct 13 09:24:15 +0000 2009 becomes %@", [frm dateFromString:@"Tue Oct 13 09:24:15 +0000 2009"]);
    

    此代码打印出来:

    2009-10-13 11:37:40.334 test2[1704:20b] Tue Oct 13 09:24:15 +0000 2009 becomes (null)
    
    1 回复  |  直到 15 年前
        1
  •  2
  •   Douglas Mayle    15 年前

    [frm setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
    
    推荐文章