开发者

iPhone - crazy timestamp

I have this code

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-mm-dd'T'HH:mm:ss.SSSSS"];

NSDate *date = [NSDate date];

NSString *timeStamp = [dateFormatter stringFromDate:date];

after开发者_StackOverflow running this date is equal to

2010-11-05 21:45:56 GMT

and timeStamp is equal to

2010-45-05T21:45:56.46700

month = 45 ???????????????????????????

any solution for this? Thanks.


mm is for minutes. You want MM for months.

iPhone uses the Unicode Standards for date formatting. MM will give you the number of the month, prefixing 0 if necessary to have 2 digits, M will give you the number of the month without the leading 0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜