开发者

Unknown NSDate format

开发者_运维技巧I have the following string to convert to NSDate:

2011-04-27 20:50:09.000002.

I have the following code for the dateformatter:

  [inputFormatter setDateFormat:@"YYYY-mm-dd HH:mm:ss"];

but I'm unsure of what to put after the seconds.

Keep in mind, I have multiple of these strings, with different numbers at the back.


Date format strings in OS 10.6 (and, I believe, in iOS4+) are based on the Unicode spec TR35-10 : have a look at their date formatting strings.

What you need in this case is fractional seconds: symbol S. Something like...

[inputFormatter setDateFormat:@"YYYY-mm-dd HH:mm:ss.SSSSSS"];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜