jylee
jylee

Reputation: 843

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.

Upvotes: 0

Views: 104

Answers (1)

Adam Wright
Adam Wright

Reputation: 49376

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"];

Upvotes: 4

Related Questions