h4wkeye
h4wkeye

Reputation: 379

Format string for NSDateFormatter to produce milliseconds

Since my date is well formatted now all there is left for me to do is to print milliseconds too.

I already tried setDateFormat yyyy/mm/dd hh:mm:ss:ms

That didn't work. Any advice?

Upvotes: 17

Views: 9163

Answers (2)

Savitha
Savitha

Reputation: 561

Try this format:

"yyyy/MM/dd HH:mm:ss.SSS"

Upvotes: 9

Vladimir
Vladimir

Reputation: 170829

Try to use 'SS' specifier (with number of S's equal to number of digits you want to get - 3 in your case), e.g.

[formatter setDateFormat:@"yyyy/MM/dd hh:mm:ss:SSS"];

Upvotes: 40

Related Questions