NSDateformatter问题

时间:2010-03-26 11:19:29

标签: iphone nsdate nsdateformatter

我在NSDateformatter和NSDate上看过很多问题,但没有人可以帮助我。

[formatter setDateFormat:@"yyyy/mm/dd"];
        NSDate *date = [formatter dateFromString:@"2010/03/10"];
        if (date) {
            NSLog(@"Date returned:::%@",date);
            return date;
        }

Probelm是这样的,它返回日期---'2010-01-10 00:03:00 +0600'月份变为1而分钟变为3,可能是什么问题?< / p>

2 个答案:

答案 0 :(得分:2)

使用MM月份,而不是mm。请参阅Unicode Standard以供参考。

答案 1 :(得分:2)

使用

[formatter setDateFormat:@"yyyy/MM/dd"];

正在考虑小mm到分钟,这就是为什么我猜...