开发者

iPhone - crazy timestamp

开发者 https://www.devze.com 2023-01-23 13:14 出处:网络
I have this code NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@\"yyyy-mm-dd\'T\'HH:mm:ss.SSSSS\"];

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

精彩评论

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