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.
精彩评论