my NSDateFormatter works only in the iPhone simulator

后端 未结 7 2053
独厮守ぢ
独厮守ぢ 2020-12-20 04:13

I use a NSDateFormatter which works fine in the simulator, but I get a nil when I run it in the iPhone. I hardcoded the date to be sure of the format, but it fails anyway. <

相关标签:
7条回答
  • 2020-12-20 04:40

    strptime rescued me aswell.

    struct tm time;
    if (strptime([modDateString UTF8String], "%A, %d %b %Y %H:%M:%S", &time)) {
                NSString *rDate=[NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d +0000",
                                 time.tm_year+1900, time.tm_mon+1, time.tm_mday,
                                 time.tm_hour, time.tm_min, time.tm_sec];
    

    This code works with HTTP dates like Thu, 15 Apr 2010 13:53:56 GMT and Fri, 8 May 2009 08:08:35 GMT which was the original question

    0 讨论(0)
提交回复
热议问题