加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – dateFromString返回nil

发布时间:2020-12-14 17:56:06 所属栏目:百科 来源:网络整理
导读:这是我的NSString, myDate : 2011-06-07 11:23:47 0000 这是代码, NSTimeZone *currentDateTimeZone = [NSTimeZone defaultTimeZone];NSDateFormatter *currentDateFormat = [[NSDateFormatter alloc]init];[currentDateFormat setTimeZone:currentDateTimeZ
这是我的NSString,

myDate : 2011-06-07 11:23:47  0000

这是代码,

NSTimeZone *currentDateTimeZone = [NSTimeZone defaultTimeZone];
NSDateFormatter *currentDateFormat = [[NSDateFormatter alloc]init];
[currentDateFormat setTimeZone:currentDateTimeZone];
[currentDateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"];
NSDate *tempDate = [currentDateFormat dateFromString:second];

仍然tempDate得到的值为零.
有人可以帮忙吗?

解决方法

你是怎么得到日期字符串的?它需要在2011-06-07 11:23:47 0000才能发挥作用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读